FragmentTranscation使用时remove(),replace()使用无效的问题
来源:互联网 发布:淘宝漏洞微信群 编辑:程序博客网 时间:2024/09/21 09:04
今天在使用Fragment的时候在xml添加了下面一段代码
<FrameLayout android:id="@+id/frag_contain" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="9"> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:name="mypro.app.com.mypro.Fragment.FirstPageFragment" android:tag="f1"/></FrameLayout>
在onClick()方法中无论怎么调用
getFragmentManager().beginTranscation().remove(fragment).commit();
或者
replace(...)方法都没办法吧FrameLayout里面的fragment去掉。
后来在网上阅读Fragment文档的时候发现在xml中添加的Fragment是没办法被remove(...)或replace(...)掉的。
所以解决方法就是将上面的FrameLayout中的fragment去掉,在onCreate(),或者框架中初始化View的地方使用add(...),将初始的Fragment添加进去。
这时候就可以使用remove(...),replace(...)方法将它去掉用别的Fragment替代了
0 2
- FragmentTranscation使用时remove(),replace()使用无效的问题
- 使用Replace时遇到的问题
- 关于无效使用 Null: 'Replace'
- 关于无效使用 Null: 'Replace'
- 使用exslt str:replace template时遇到的问题
- javascript replace的使用
- MySQL Replace 的使用
- javascript replace的使用
- ant replace的使用
- mysql replace的使用
- Fragment replace的使用
- 使用List的Remove方法时想起的小问题
- 使用List中remove方法时需要注意的问题
- List使用remove(index);遇到的问题;
- Android中使用自定义Dialog时match_parent无效的问题
- 使用replace函数更新数据类型ntext无效怎么办
- android 滤镜使用无效的小问题
- java中replace 和replaceAll使用遇到的问题:
- MVC与MVP
- CentOS上yum安装 jdk
- 应用发布托管平台
- cocos2d_lua播放动画
- javaSocket多次传输没有重新初始化的一个对象接收端只会接收到第一个对象的值
- FragmentTranscation使用时remove(),replace()使用无效的问题
- popupwindow在顶部或底部出现,背景变暗
- 使用FragmentTabHost出现的错误!
- View的事件分发机制(一)
- 秒杀多线程第十篇 生产者消费者问题
- JQuery+ajax+jsonp 跨域访问
- 《ECMAScript 6入门》——JavaScript
- Android 用MediaCodec实现视频硬解码
- android自动化测试 Monkey