Fragment销毁时replace和add两个方法的区别
1个回答
展开全部
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.layout = (FrameLayout) this.findViewById(R.id.content);
int i = 0;
while (i < 10) {
FragmentManager fm = this.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.content, new OneFragment());
ft.commit();
i++;
}
}
@Override
protected void onResume() {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.layout = (FrameLayout) this.findViewById(R.id.content);
int i = 0;
while (i < 10) {
FragmentManager fm = this.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.content, new OneFragment());
ft.commit();
i++;
}
}
@Override
protected void onResume() {
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询