不推荐使用 Android TabHost [英] Android TabHost deprecated
问题描述
我正在创建支持 Android 2.2
到 Android 4.1
的应用程序.TabHost
在 Android 3.2 版中已弃用
.但是创建的应用程序支持所有versions
.但我想创建 Tab bar
应用程序,当在 Android 4.2 中运行应用程序时,它看起来像
tab bar
in Android 4.1
,如果我在低于 android 3.2 版本
的设备上运行该应用程序,它必须看起来像该设备中的 标签栏
.我该怎么做.?
I am creating application which will support Android 2.2
to Android 4.1
. The TabHost
is deprecated in Android version 3.2
. But the created application supported in all the versions
. But I want to create the Tab bar
application which will look like a tab bar
in Android 4.1
while running the application in Android 4.2
, If I am running the application in below android 3.2 version
device, it must look like the tab bar
in that device. How can I do this.?
推荐答案
你的问题有很多点,
TabHost
未已弃用然而.最近 Google 弃用了TabActivity
和ActivityGroup
.- 即使它被弃用,也不意味着它不能被使用.如果 X 已被弃用,则仅意味着存在名为 Y 的更好替代方案.
TabHost
is not deprecated yet. Recently Google deprecatedTabActivity
andActivityGroup
.- Even if it deprecated, it doesn't mean it can't be used. If X is deprecated, it only means a better alternative named Y is there.
现在回答你的问题,你有不止一种选择
Now to answer your question, You have more than one options
- 您可以按照其他答案的建议使用 ActionBarSherlock.(ActionBarSherlock 现在已弃用.)
- 您可以将
TabHost
与片段一起使用,请参阅我的回答 这里好的例子.要在 3.0 之前的 API 中使用Fragment
,您需要使用Google 的支持库.
- You can use ActionBarSherlock as other answers suggests. (EDIT : ActionBarSherlock is now deprecated.)
- You can use
TabHost
with fragments, See my answer here for a good example. To useFragment
in pre 3.0 API's you need to use Google's support library.
这篇关于不推荐使用 Android TabHost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!