Comments (3)
@lylzwsy 看你的描述,你的是同级的使用场景,不是流程式的;(类知乎)你想做到这个效果的话需要这样:
我假设你还有另外2个同级模块,AFragment和BFragment,那么你的Activity层的Fragment栈内应该只有3个Fragment,Main、A、B。 这3个Fragment仅仅是容器作用,MainFragment里的内容是它的子Fragment,向里面流程式跳转的话,就是子Fragment之间的跳转;
你可以想象各个模块之间的切换是很复杂的,嵌套关系要理清。
我的README里最后有提到,目前该版本暂不能帮你恢复 同级 以及 Fragment嵌套的情况(因为很复杂~),所以如果你想在这种同级的场景下使用的话,你需要做以下2点:
1、你需要在MainActivity里自己做 内存重启 时的恢复工作(MainFragment、AFragment、BFragment的恢复)
2、你需要在MainFragment、AFragment、BFragment里自己做 内存重启 时的恢复工作(参考SupportActivity)
综上,如果你一定需要这样需求的话,就需要这么做;我的Demo可以看到是流程式的;不需要任何额外的处理,库已经帮助处理好了
最后,下个版本0.7可能会解决 Fragment嵌套、同级的恢复问题(已经找到封装思路,还在尝试封装中)
:)
from fragmentation.
@lylzwsy 同时还一种方案是我比较提倡的,就是少量模块Activity+多Fragment,首页还是MainActivity+3个模块Fragment,每个模块点击的话就是跳转Activity,然后该Activity是单Activity+多Fragment的结构
3个模块都是这样处理 那么你的app就是4 Activity+多Fragments, 这样处理的话代码复杂程度和Fragment之间的嵌套逻辑会降到最低,同时app质量和性能又比较高,你可以酌情考虑
当然你看下你的app是不是一定需要首页是同级的,不然的话可以参考我的demo那种结构,一样是可行且简单的
:)
from fragmentation.
非常感谢你。 我再继续研究研究。 同时也期待你的0.7版本!加油。
from fragmentation.
Related Issues (20)
- viewpager嵌套viewpager,中第二个viewpager中的onLazyInitView和onSupportVisible步骤 HOT 1
- 不维护可能是随着谷歌逐步对fragment的优化,作者觉得越来越鸡肋了吧 HOT 2
- 结合ViewPager的父布局底部会被键盘顶起 HOT 3
- 废弃的原因是什么 HOT 4
- fragment栈的问题 must call loadRootFragment first HOT 1
- EasyFragmentation
- google 官方fragment 导航框架 navigation-fragment+navigation-ui HOT 7
- 消息队列管理为什么size==1才执行 ,如果>1 那么岂不是无法执行了? HOT 2
- viewpager上有输入框,输入框会把底部导航栏顶起来怎么怎么解决 HOT 1
- Fragmentation升级版, 欢迎试用
- 这么好的开源库放弃更新太可惜了,有大佬能和作者接触下接手吗? HOT 5
- 字体大小异常问题
- Fragmentation升级版,欢迎试用 HOT 1
- 如果viewpager在activity第一层级,初始化的时候viewpager中所有fragment的onLazyInitView都会被回调 HOT 2
- 为什么在Handler.post里调用onSupportVisible, 而不是直接调用? HOT 1
- popTo() has not been attached yet HOT 2
- onSupportVisible 在三星note5、s6上 不可用
- JCenter to be dismissed - please migrate to Maven Central HOT 1
- 使用popTo方法时被pop的Fragment不会调用onDestroy方法
- pop 动画在高版本(SDK 31,androidx.fragment 1.3.6)上异常
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fragmentation.