android:如何使用tabhost/tabwidget(genrally tabs)在tabcontents上放置不同的活动

android:如何使用tabhost/tabwidget(genrally tabs)在tabcontents上放置不同的活动,android,Android,首先!, 我使用了选项卡导航类型生成的活动。我只是用它在活动上自动生成选项卡控件。这是最新的广告。我想:(,),, 现在,我的问题是如何将其他活动中的片段用于选项卡内容 第二,, 有没有其他方法可以将另一个活动放在选项卡内容中,比如它的MainACtivity.class 计划有3个选项卡s,其中包含3个不同的活动s,每个选项卡内容包含1个活动 真的需要你的帮助,伙计们,我的想法和资源都用完了。。。 android开发有点陌生,所以要温和一些。tab.xml: <?xml version=

首先!, 我使用了选项卡导航类型生成的
活动
。我只是用它在
活动
上自动生成
选项卡
控件。这是最新的广告。我想:(,),, 现在,我的问题是如何将其他
活动
中的
片段
用于
选项卡
内容

第二,, 有没有其他方法可以将另一个
活动
放在
选项卡
内容中,比如它的MainACtivity.class

计划有3个
选项卡
s,其中包含3个不同的
活动
s,每个
选项卡
内容包含1个
活动

真的需要你的帮助,伙计们,我的想法和资源都用完了。。。 android开发有点陌生,所以要温和一些。

tab.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">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
         >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_marginTop="60dp"/>
       <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp"/>
    </RelativeLayout>

</TabHost>
同样,您可以在活动中添加尽可能多的选项卡。

tab.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">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
         >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_marginTop="60dp"/>
       <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp"/>
    </RelativeLayout>

</TabHost>

同样,您可以在活动中添加尽可能多的选项卡。

hmmm部分tabHost=getTabHost()不是假定为findById(,,,)获取tabhost的东西?…因为我遇到了一个错误,我实现了这个,它运行良好。清理项目并再次运行,它不会给你错误。如果它这样做,那么就发布错误。通过android.app.TabActivity而不是activity扩展活动。你不会得到错误。哦,很好,我得到了它。tnx AkashG…顺便说一句,它已经被弃用了:D just sayinhmmm不是tabHost=getTabHost()假定为findById(,,,)的部分获取tabhost的东西?…因为我遇到了一个错误,我实现了这个,它运行良好。清理项目并再次运行,它不会给你错误。如果它这样做,那么就发布错误。通过android.app.TabActivity而不是activity扩展活动。你不会得到错误。哦,很好,我得到了它。tnx AkashG…顺便说一句,它已经被弃用了:D just sayini在我的答案中做了一些更改,请看一眼。本教程可能会帮助您我在我的答案中做了一些更改,请看一眼。本教程可能会帮助您