首先!
我使用了标签导航类型使用了生成的Activity
。我只是用它来Tab
自动生成Activity
控件。它在最新的 ADT 。我想:( ,,
现在我的问题是如何使用其他Fragments
中的Activity
到Tab
内容
其次,
有没有其他方法可以将另一个Activity
放在Tab
内容中,让我们说它的MainACtivity.class?....
计划包含3个Tab
个3个Activity
个,每个Activity
个tab
个{{1}}
真的需要你的帮助,我已经用完了想法和来源:( :( ... 一种新的android开发所以要温柔。 :)
答案 0 :(得分:1)
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>
在activity.java文件中添加以下代码:
将您的活动延长android.app.TabActivity
而不是Activity
TabHost tabHost=getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent=new Intent().setClass(YourActivity.this, NewActivity.class);
spec=tabHost.newTabSpec("tab1").setIndicator("imageId").setContent(intent);
tabHost.addTab(spec);
intent=new Intent().setClass(YourActivity.this, New1Activity.class);
spec=tabHost.newTabSpec("tab2").setIndicator("imageId").setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
以同样的方式,您可以在活动中添加任意数量的标签。