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的更多相关文章

  1. Android Fragment 生命周期及其API使用(建议使用自定义View替换Fragment)

    我为什么不主张使用Fragment Fragment:( Fragment就相当于一个有生命周期的View,它的生命周期被所在的Activity的生命周期管理 ) 生命周期回调说明: onAttach ...

  2. Android Fragment 生命周期及其正确使用(建议使用自定义View替换Fragment)

    使用Fragment 官方例子中显示: 例如:一个学生Fragment,需要传入studentId,进行http请求显示,那么setArguments后防止杀掉Fragment后,参数为0,显示不了数 ...

  3. 【Android自学日记】【转】Android Fragment 真正的完全解析(下)

    上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和各种API,如果你还不了解,请看:Android Fragment 真正的完全解析(上). 本篇将介绍上篇博客提到的:如何管理Frag ...

  4. Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误

    嵌套Fragment的使用及常见错误 嵌套Fragments (Nested Fragments), 是在Fragment内部又添加Fragment. 使用时, 主要要依靠宿主Fragment的 ge ...

  5. Android Fragment使用(一) 基础篇 温故知新

    Fragment使用的基本知识点总结, 包括Fragment的添加, 参数传递和通信, 生命周期和各种操作. Fragment使用基础 Fragment添加 方法一: 布局里的标签 标识符: tag, ...

  6. Android Fragment 真正的完全解析(下)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/37992017 上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和 ...

  7. Android Fragment 解析和使用

    Android Fragment的生命周期和Activity类似,实际可能会涉及到数据传递,onSaveInstanceState的状态保存,FragmentManager的管理和Transactio ...

  8. android fragment 博客 学习记录

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/37992017 上篇博客中已经介绍了Fragment产生原因,以及一些基本的用法和 ...

  9. Android Fragment详解

    一.什么是Fragment Android在3.0中引入了fragments的概念,主要目的是用在大屏幕设备上--例如平板电脑上,支持更加动态和灵活的UI设计.平板电脑的屏幕要比手机的大得多,有更多的 ...

随机推荐

  1. 注意,WebDeploy服务会占用80端口。(Windows关闭了IIS,80端口任然被占用)

    最近遇到一个很奇怪的事情,Windows上的 IIS 网站 全关掉了,80端口仍然被占用.然后我新装了一台服务器,一个一个组件地装,装一个测一次,最后发现,WebDeploy这个组件,会占用80端口. ...

  2. Math.random引发的骗术,绝对是用随机数骗前端妹纸的最佳方法

    我觉得今天我运气特好,今天我们来赌一赌,我们来搞个随机数,Math.floor(Math.random() * 10),如果这个数等于0到7,这个月的饭,我全请了,如果是8或9,你就请一个礼拜成不?于 ...

  3. [Elasticsearch] 集群工作 - 第二部分

    本文翻译自Elasticsearch官方指南的life inside a cluster一章. 添加故障转移(Failover)功能 仅仅执行一个节点意味着可能存在着单点失败(Single point ...

  4. automake/autoconf的简单例子

    参考文章1:http://loftor.com/archives/automake.html 参考文章2:http://www.blogjava.net/huyi2006/articles/18790 ...

  5. 定制openwrt的根文件

    都在package文件夹之中 1 ssh登陆欢迎文字,在package/base-files/files/etc/banner中 2 路由器的默认机器名字,在package/base-files/fi ...

  6. Inno Setup 网页显示插件 webctrl

    原文:Inno Setup 网页显示插件 webctrl ; -- Example.iss -- ; restools ; http://restools.hanzify.org ; 插件名:webc ...

  7. asp.net请求响应模型原理随记回顾

    asp.net请求响应模型原理随记回顾: 根据一崇敬的讲师总结:(会存在些错误,大家可以做参考) 1.-当在浏览器输入url后,客户端会将请求根据http协议封装成为http请求报文.并通过主sock ...

  8. DDD(领域驱动设计)理论结合实践

    DDD(领域驱动设计)理论结合实践   写在前面 插一句:本人超爱落网-<平凡的世界>这一期,分享给大家. 阅读目录: 关于DDD 前期分析 框架搭建 代码实现 开源-发布 后记 第一次听 ...

  9. 调式WP程序报0x80131500错误的解决办法

    在虚拟机上安装了win8系统和VS2013,但是在允许第一个WP程序时,居然报0x80131500错误信息,经查询原来是VS2013需更新的问题,如果你用的是VS2012,但是又系统升级到了win8. ...

  10. Installutil.exe的位置和路径

    安装程序工具使您得以通过在执行指定程序集中的安装程序组件来安装和卸载服务器资源.此工具与 System.Configuration.Install命名空间中的类一起工作.安转的位置和路径在:C:\WI ...