用这个方法吧,切换第二个fragment的时候,要先把之前那个remove,然后再add进去的所以建议使用replace,会自己把之前那个移除,再增加,请查看相关apitransaction.replace(id,fragment);