标签:
frament可以由自动添加,主要代码如下:
FragmentManager fm = getSupportFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); mDemo = new DemoFragment(); transaction.replace(R.id.fragment_content, mDemo); transaction.commit();
同时可以对每次fragment的操作增加回退栈,增加后back键的操作将首先处理fragment的回退,如下:
FragmentManager fm = getSupportFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); mDemo = new DemoFragment(); transaction.replace(R.id.fragment_content, mDemo);//replace = remove + add transaction.addToBackStack(null); transaction.commit();
标签:
原文地址:http://www.cnblogs.com/Fredric-2013/p/4356734.html