Android:FragmentTransaction的commit 和addToBackStack的方法随记

来源:互联网 发布:数据库存储emoji表情 编辑:程序博客网 时间:2024/05/18 02:43
1)commit():The commit does not happen immediately  ft.add(id,fragment,tag).commit();  Fragment f=fm.findFragmentByTag(tag);// 此时找不到Fragment,fragment为null
2)addToBackStack(null):用了此法方法,按返回键,可以返回上一个添加的Fragment
英文官方解释:
Add this transaction to the back stack.  This means that the transactionwill be remembered after it is committed, and will reverse its operationwhen later popped off the stack.         
stack的特点:后进先出

                                             
0 0