我正在使用 android 2.1 开发应用程序。在一个页面中,上部有两个文本视图,下部有标签布局,有两个选项卡。
我的 XML 代码是这样的......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include android:id="@+id/content" layout="@layout/content_table"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabHost" android:layout_below="@+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<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="wrap_content" />
</LinearLayout>
</TabHost>
</RelativeLayout>
活动课就像...
public class PageActivity extends ActivityGroup {
LogoBarActivity logoBar;
TabHost mTabHost;
TextView text1;
TextView text2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.page);
text1 = findViewById(R.id.textview1);
text2 = findViewById(R.id.textview2);
mTabHost = (TabHost) findViewById(R.id.tabHost);
mTabHost.setup(this.getLocalActivityManager());
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, Type1Activity.class);
spec = mTabHost.newTabSpec("type1").setIndicator("Type1").setContent(intent);
mTabHost.addTab(spec);
intent = new Intent().setClass(this, Type2Activity.class);
spec = mTabHost.newTabSpec("type2").setIndicator("Type2").setContent(intent);
mTabHost.addTab(spec);
mTabHost.setCurrentTab(0);
mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height /= 2;
mTabHost.getTabWidget().getChildAt(1).getLayoutParams().height /= 2;
}
}
说明:当用户来到这个页面时,他可以点击 Type1 或 Type2 上的任何选项卡。两个选项卡都有 ListView (Type1Activity 和 Type2Activity 是 ListView )。当用户单击任何选项卡时,他将在选项卡中获得 ListView。用户可以从列表视图中选择任何项目,该项目将分别设置在 PageActivity 类的 text1 和 text2 变量中。
问题:当用户从任何选项卡的列表视图中选择任何项目时,如何将选项卡活动的结果返回到我的 PageActivity。