android fragment addToBackStack bug
In FragmentActivity。First, I add two fragment by FragmentTransaction。
See the flowing code :
/******************************************************/
MyFragmentManager manager;
FragmentTransaction fragmentTransaction;
FragmentManager fragmentManager;
MainBottomFragment bottom;
fragmentManager = getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction();
manager = new MyFragmentManager(this);
Fragment bottomFragment = new MainBottomFragment(this);
Fragment homePageFragment= new HomePageFragment(this);
fragmentTransaction.add(R.id.common_bottom, bottomFragment);
fragmentTransaction.add(R.id.common_top, homePageFragment= );
fragmentTransaction.commit();
/******************************************************/
Second,In homePageFragment fragment,I need to deal with one button click event to next fragment(A),
then in Fragment,I processing then:
/******************************************************/
getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.common_top, A);
/******************************************************/
Third,In A fragment,I need to deal with one button click event to next fragment(B),
then in Fragment,I processing then:
/******************************************************/
getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.common_top,B);
/******************************************************/
Fouth,now B fragment is in the top,When I press the return key, the current fragment's order is
B->A->homeFragment,there is not problem with the above four stops;
But in the second step,if you replace fragment without call addToBackStack(null) method,like this:
getSupportFragmentManager().beginTransaction().replace(R.id.common_top, A);
When the top fragment is B,When I press the return key, the current fragment's order is
B->homeFragment accourding to Google's official Android documentation,But is not consistent with what I expected。
Is anybody call tell me why? How do I solve this problem?
thans a lot.
android fragment addToBackStack bug的更多相关文章
- Android Fragment 生命周期及其API使用(建议使用自定义View替换Fragment)
我为什么不主张使用Fragment Fragment:( Fragment就相当于一个有生命周期的View,它的生命周期被所在的Activity的生命周期管理 ) 生命周期回调说明: onAttach ...
- Android Fragment 生命周期及其正确使用(建议使用自定义View替换Fragment)
使用Fragment 官方例子中显示: 例如:一个学生Fragment,需要传入studentId,进行http请求显示,那么setArguments后防止杀掉Fragment后,参数为0,显示不了数 ...
- 【Android自学日记】【转】Android Fragment 真正的完全解析(下)
上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和各种API,如果你还不了解,请看:Android Fragment 真正的完全解析(上). 本篇将介绍上篇博客提到的:如何管理Frag ...
- Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误
嵌套Fragment的使用及常见错误 嵌套Fragments (Nested Fragments), 是在Fragment内部又添加Fragment. 使用时, 主要要依靠宿主Fragment的 ge ...
- Android Fragment使用(一) 基础篇 温故知新
Fragment使用的基本知识点总结, 包括Fragment的添加, 参数传递和通信, 生命周期和各种操作. Fragment使用基础 Fragment添加 方法一: 布局里的标签 标识符: tag, ...
- Android Fragment 真正的完全解析(下)
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/37992017 上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和 ...
- Android Fragment 解析和使用
Android Fragment的生命周期和Activity类似,实际可能会涉及到数据传递,onSaveInstanceState的状态保存,FragmentManager的管理和Transactio ...
- android fragment 博客 学习记录
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/37992017 上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和 ...
- Android Fragment详解
一.什么是Fragment Android在3.0中引入了fragments的概念,主要目的是用在大屏幕设备上--例如平板电脑上,支持更加动态和灵活的UI设计.平板电脑的屏幕要比手机的大得多,有更多的 ...
随机推荐
- C语言得到当前系统时间
void getTime(){ //获取当前系统时间 time_t tTime;//距离1900年1月1日的秒数 char str[80]; struct tm* stTim;//时间结构 time( ...
- [Elasticsearch] 邻近匹配 (一) - 短语匹配以及slop參数
本文翻译自Elasticsearch官方指南的Proximity Matching一章. 邻近匹配(Proximity Matching) 使用了TF/IDF的标准全文搜索将文档,或者至少文档中的每一 ...
- Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by
配置php网站的时候,经常会在页首出现Warning: session_start() [function.session-start]: Cannot send session cache limi ...
- Java替换字符或十进制数的字符串
如今,这个项目的需求:将"甲状腺结节 5*3 cm" 更换 "甲状腺结节 * cm". 在一个字符串的数字来替换空白. 码,如以下: public static ...
- VMware Linux 下 Nginx
负载 VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三) Weiseditor 2014-11-26 23:42 阅读:1 评论 ...
- MyEclipse新建Web Project报错
1.详细报错例如以下图 2.报错原因 3.解决方法
- 简话ASP.NET Web API
简话ASP.NET Web API 在vs2012中,我们很容易在根据选择的ASP.NET MVC Web应用程序来新建一个Web API应用,聪明的你一定想见得到,Web API和MVC有着某种联系 ...
- Yeoman入门之安装及环境配置
Yeoman入门之安装及环境配置 http://blog.csdn.net/panlingfan/article/details/27345037 http://www.nodejs.orgYEOMA ...
- UrlRouting的理解
UrlRouting的理解 文章内容 根据对Http Runtime和Http Pipeline的分析,我们知道一个ASP.NET应用程序可以有多个HttpModuel,但是只能有一个HttpHand ...
- 看AngularJS
最近一段时间一直在看AngularJS,趁着一点时间总结一下. 官网地址:http://angularjs.org/ 先推荐几个教程 1. AngularJS入门教程 比较基础,是官方Tutorial ...