当选项卡活动被弃用时,我该怎么办



我尝试使用选项卡活动制作项目。但问题是当我声明选项卡活动不起作用时。当我把鼠标放在上面时,它会显示这个文档

This class is deprecated. New applications should use Fragments instead of this class; to continue to run on older devices, you can use the v4 support library which provides a version of the Fragment API that is compatible down to DONUT..... bla.....bla....bla .

我认为我的填充不正确,所以我修复了 xml,但它仍然是一样的。这是我的标签的 xml。

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>

我该如何解决问题?

在软件开发领域,"弃用"是指正在被较新的函数或元素取代的功能或元素,因此您可以使用FragmentTabs而不是TabActivity

我认为您正在为您的应用程序实现 TabGroupActivity 实现,该应用程序将 Tab 设置为活动组,ActivityGroup 已从 Android API 中弃用,因此根据建议,您应该使用片段而不是 TabGroup。请参阅示例:

http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.html

http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

最新更新