Android: stack management for views in a tab?

♀尐吖头ヾ 提交于 2020-01-14 14:41:07

问题


I see some answers here prefer views over activities as contents of tabs. Correct me if I am wrong. My understanding is that by switching out views, it's possible to keep the navigation flow inside a tab (more user friendly, I think). But I wonder how to manage the view stack then in case of the back button events. Also this could cause one giant Activity with large amount of views, which might not be good.

So I wish to know why exactly views as contents is preferred before I change my current application to this.

Thanks,


回答1:


I see some answers here prefer views over activities as contents of tabs.

A lot of those would be mine.

more user friendly, I think

I completely disagree on this point. I feel that trying to fake navigation inside of tabs is a mistake for most mobile applications.

Also this could cause one giant Activity with large amount of views, which might not be good.

If it is too big from a memory standpoint, it will be too complicated from a user's standpoint, and so should be broken up into independent activities (without tabs).

So I wish to know why exactly views as contents is preferred before I change my current application to this.

Using Activities as the contents of tabs makes all of your concerns worse. Using Activities as the contents of tabs takes up more memory, because more Views get created beyond those you declare in an activity. Using Activities as the contents of tabs takes up a few layers more of stack space, one of the most precious commodities in Android. Using Activities as the contents of tabs takes up CPU time, as Android has to unravel your activity to get at the View inside of it, anyway.

I would flip the issue around: nobody has yet to demonstrate to me any advantage to having Activities as the contents of tabs that outweighs these disadvantages.



来源:https://stackoverflow.com/questions/2890617/android-stack-management-for-views-in-a-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!