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. Bootstrap的栅格系统

    Bootstrap的栅格系统 上一节:ASP.NET MVC5 + EF6 入门教程 (6) View中的Razor使用 源码下载:点我下载 要做一个完整的系统,除了需要MVC这样的B/S框架及EF这 ...

  2. 为JS字符类型添加trim方法

    JS字符串本身并不没有提供常用的trim方法,我们可以通过修改String原形来添加此方法,我们就可以直接调用此方法了: String.prototype.trim = function(){retu ...

  3. 1.3 LINQ查询

    LINQ最具突破性的优势在于将文本查询与对象操作完美集成,它让查询数据和操作对象一样安全和轻松.查询(Query)是LINQ的核心概念之一. 传统意义上的数据查询语言,通常是比较易懂,具有一定语义的文 ...

  4. iOS文档序列化(对象归档)

    对象归档: 概念: 对象归档是指将对象写入文件保存在硬盘,当再次又一次打开程序时,能够还原这些对象.也称:对象序列化.对象持久化. 数据持久性的方式(事实上就是3类) 1,NSKeyedArchive ...

  5. 区域、模板页与WebAPI初步

    区域.模板页与WebAPI初步 一.区域—麻雀虽小,五脏俱全的迷你MVC项目 1.1 Area的兴起 为了方便大规模网站中的管理大量文件,在ASP.NET MVC 2.0版本中引入了一个新概念—区域( ...

  6. Visual Studio 2013发布Cloud Service至Azure China

    Visual Studio 2013发布Cloud Service至Azure China <Windows Azure Platform 系列文章目录> 之前有很多网友询问我如何通过VS ...

  7. [置顶] 如何使用c3p0+spring连接oracle数据库

    1. 首先是jdbc.properties属性文件的编写,便于数据库移植: datasource.driverClassName=oracle.jdbc.driver.OracleDriver dat ...

  8. KMP 代码 暂存

    #include <stdio.h> #include <string.h> ],B[]; ]; int n, m; void _next(){ ; ; next[] = ; ...

  9. .NET编程规范

    .NET开发编程规范 第1章 程序的版式 版式虽然不会影响程序的功能,但会影响可读性.程序的版式追求清晰.美观,是程序风格的重要构成因素. 可以把程序的版式比喻为"书法".好的&q ...

  10. DOM(二) 判断节点包含关系

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...