下面是我在布局中添加标签的代码。
public class MyexplistActivity extends ExpandableListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tryout);
TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
tabHost.setup();
TabSpec browsespec=tabHost.newTabSpec("Tab 1");
browsespec.setIndicator("Browse", getResources().getDrawable(R.drawable.icon_browse_tab));
browsespec.setContent(R.id.tab1);
TabSpec advspec=tabHost.newTabSpec("Tab 2");
advspec.setIndicator("Advanced Search", getResources().getDrawable(R.drawable.icon_advsrch_tab));
advspec.setContent(R.id.tab2);
TabSpec tgspec=tabHost.newTabSpec("Tab 3");
tgspec.setIndicator("Tagged Files", getResources().getDrawable(R.drawable.icon_tgfiles_tab));
tgspec.setContent(R.id.tab3);
tabHost.addTab(browsespec);
tabHost.addTab(advspec);
tabHost.addTab(tgspec);
}
}
试用.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabHost"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs"
/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabcontent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tab1"
android:orientation="vertical"
android:paddingTop="60px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="100px"
android:text="This is tab1"
android:id="@+id/txt1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tab2"
android:orientation="vertical"
android:paddingTop="60px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="100px"
android:text="This is tab 2"
android:id="@+id/txt2"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tab3"
android:orientation="vertical"
android:paddingTop="60px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="100px"
android:text="This is tab 3"
android:id="@+id/txt3"
/>
</LinearLayout>
</FrameLayout>
</TabHost>
现在我的问题是我想在点击 tab1 时调用另一个类 annotate.java 以便完成后台编码。那么这样做的程序是什么?