How to support tabs on Android 2.2+?

怎甘沉沦 提交于 2019-12-25 18:13:14

问题


I'm trying to offer tab support for all Android versions 2.2 and above. Is there a way of achieving this without using any deprecated classes/methods?


回答1:


The Problem is as following: TabActivity is deprecated because it derives from ActivityGroup which is deprecated, too. Problems are, to start Activitys inside Tabs and don't break callbacks like onActivityResume. There are some 'Hacks' around which solve this but they are ALL relying on the deprecated LocalActivityManager. So I see no solution of using Tabs without ANY deprecated calls. Since Android 3.X google invented Fragments for this kind of things which are supported on lower Versions with the SupportPackage. You should definetly try them in Combination with the new ActionBar if you want to avoid deprecated classes/methods

EDIT: Link to FragmentTabs for further reference




回答2:


I recon with with the answer Rafael gave.

Instead of resorting to the TabActivity you can sill use the regular TabHost to show tabs in all versions of android.



来源:https://stackoverflow.com/questions/10913490/how-to-support-tabs-on-android-2-2

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