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. IE中的事件对象

    IE中的事件对象 1)type属性 用于获取事件类型 2)srcElement属性 用于获取事件的目标 3)cancelBubble属性 用于阻止事件冒泡 设置为true表示阻止事件冒泡  设置为fa ...

  2. hdu oj1102 Constructing Roads(最小生成树)

    Constructing Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  3. 真懂JavaScript吗

    你真懂JavaScript http://www.cnblogs.com/elegance/p/4195593.html 看了汤姆大叔的“你真懂JavaScript吗?”,里面有5道题目,我都一一作了 ...

  4. Chapter 1 Securing Your Server and Network(1):选择SQL Server业务经理

    原版的:http://blog.csdn.net/dba_huangzj/article/details/37924127  ,专题文件夹:http://blog.csdn.net/dba_huang ...

  5. android数据库升级的措辞

    在基类table增加upgrade操作: public abstract class DbBaseTable { private static final String TAG = "DbB ...

  6. 安装Windows7操作系统 - 初学者系列 - 学习者系列文章

    Windows7是一款不错的操作系统,不过它的销量远没有XP那么大,但是不失为一款好的操作系统.下面就对Windows7操作系统的安装做下介绍. 1.  同样的,BIOS里设置光驱启动,把操作系统盘装 ...

  7. 安装WindowsXP操作系统(安装版) - 初学者系列 - 学习者系列文章

    本文主要介绍下Windows XP操作系统的安装. 1.             将光驱装入光驱.启动电脑,在开始界面按下DEL键,进入BIOS设置界面.将光驱设置为第一启动项.下面以虚拟机为例子. ...

  8. 【转】webAPP快速入门

    WebApp与Native App有何区别呢? Native App: 1.开发成本非常大.一般使用的开发语言为JAVA.C++.Objective-C. 2.更新体验较差.同时也比较麻烦.每一次发布 ...

  9. Android 5.0之应用中实现材料设计—Material Design

    上午的时候在刷Google+,看到了Abraham Williams转发了一篇强文,是Android Developers网站新发的一篇博客—Implementing Material Design ...

  10. Routing(路由) & Multiple Views(多个视图) step 7

    Routing(路由) & Multiple Views(多个视图) step 7 1.切换分支到step7,并启动项目 git checkout step-7 npm start 2.需求: ...