具有无处不在的选项卡栏的应用程序中 UI 管理的最佳实践
我正在开发一个具有始终可见的选项卡栏的 Android 应用程序。
但是,每个选项卡可能包含许多嵌套的“屏幕”。
当然,后退按钮需要正确处理这个问题。
我现在花了一天的大部分时间来寻找实现这一目标的最佳架构。
stackoverflow 上也有几个类似的问题,但我找不到真正适合我的答案。我发现并尝试了两个建议:
我想到的另一种方法是将所有“屏幕”实现为正常活动,并让它们都有自己的选项卡栏(但看起来相同,因此对于用户来说它不会改变)。
我已经看到,通过在布局 xml 中使用 include 语句,应该可以不需要太多冗余代码,并且可能创建一个配置选项卡栏的公共基类“CustomActivity”。
然而,由于我还没有使用 Android 的经验,所以我想在花更多时间尝试和错误风格之前先在这里问一下。
这是一种有意义的方法吗?如果没有,更好的解决方案是什么?
顺便说一句:上面提到的建议对我不起作用,主要是因为后退按钮对我不起作用。
感谢您的每一次投入!
I'm working on an Android app having an always visible tabbar.
However, each tab potentially contains many nested "screens".
Of course the back-button needs to handle this correctly.
I've now spent most of the day finding out what's the best architecture to achieve this.
There are also several similar questions on stackoverflow, but I couldn't really find an answer working for me. Two proposals I found and tried out:
Another approach I thought about is just implement all "screens" as normal activities and have them all have their own tabbar (but looking the same, so for the user it doesn't change).
I've seen that should be possible without too much redundant code by using include statement in layout xml and maybe create a common base class "CustomActivity" which configures the tabbar.
However since I'm not yet experienced with Android, I wanted to ask here before spending more time with try and error style.
Is this an approach which makes sense? If not, what would be a better solution?
Btw: The proposals mentioned above didn't work for me mainly because with neither the back button worked for me.
Thanks for every input!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Fragments API,ActivityGroup 似乎已被弃用。
Use Fragments API, ActivityGroup seems to be deprecated.