我有一個包含圖像和列表視圖的佈局。在他們下面我需要添加標籤。 當我使用標籤小部件時,它突出顯示第一個選項卡,並在選項卡下方顯示該選項卡活動結果。 所以我必須停止第一個選項卡的活動。當點擊選項卡時,只應該調用該活動,並且應該轉到另一個屏幕。默認情況下不想突出顯示標籤
下面是我的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView android:id="@+id/imageView1"
android:background="@drawable/banner"
android:layout_width="323dp"
android:layout_height="100dp"></ImageView>
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_height="28dp" android:layout_width="fill_parent">
<ImageView android:layout_alignParentTop="true" android:onClick="mapfunction" android:layout_width="wrap_content" android:id="@+id/imageView2" android:src="@drawable/map1" android:layout_height="100dp" android:layout_marginRight="10dp" android:layout_toLeftOf="@+id/textView1"></ImageView>
<ImageView android:layout_width="wrap_content" android:id="@+id/imageView3" android:src="@drawable/listtab" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginRight="10dp" android:layout_toLeftOf="@+id/textView2"></ImageView>
<TextView android:id="@+id/textView2" android:text="LIST" android:layout_width="wrap_content" android:textStyle="bold" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/imageView2" android:layout_marginRight="14dp"></TextView>
<TextView android:id="@+id/textView1" android:text="MAP" android:layout_width="wrap_content" android:textStyle="bold" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView3" android:layout_alignParentRight="true" android:layout_marginRight="31dp"></TextView>
</RelativeLayout>
<ListView android:id="@id/ListView01" android:layout_width="fill_parent" android:layout_height="253dp"></ListView>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent" android:layout_height="44dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="34dp"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:padding="5dp" android:layout_height="fill_parent"/>
</TabHost>
</LinearLayout>
下面是顯示的標籤我的活動代碼。
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, Contacts.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("places").setIndicator("PLACES",
res.getDrawable(R.drawable.places))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, Contacts.class);
spec = tabHost.newTabSpec("camera").setIndicator("CAMERA",
res.getDrawable(R.drawable.camera))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
它在做什麼,你想要做什麼?它在做x,但我希望它做y。我無法從你上面的問題中解析出來。 – 2012-01-06 14:15:18
我的問題很簡單,我不想強調默認 – Vamshi 2012-01-06 14:18:14
標籤通過突出顯示,你的意思是它不應該默認顯示的任何頁面(然後會發生什麼)?或者它被塗成橙色(或者你的皮膚使用的任何顏色)? – 2012-01-06 14:24:40