Я занимаюсь разработкой приложения с использованием 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 во вкладках. Пользователь может выбрать любой элемент из списка, и этот элемент будет установлен в переменные text1 и text2 класса PageActivity соответственно.
Вопрос: Как вернуть результат активности вкладок в мою PageActivity, когда пользователь выбирает любой элемент из списка в любой вкладке.