請問一下該如何修改 (TabActivity)
應該如何讓tab裡面擁有多個button
但是彼此tab不會互相干擾
我目前狀況是
可以在第一個tab上顯示多個button
可是在第二個tab 會出現 第一個tab裡的button
這該怎麼解決?
=========以下為程式碼============
package com.android.demo.tabTest2;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;
public class TabTest2 extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("", getResources().getDrawable(R.drawable.aa)).setContent(R.id.content1));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.content2));
mTabHost.setCurrentTab(0);
}
}
=====main.xml======
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginTop="25dip"
android:text="a" />
android:id="@+id/button1_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
android:layout_alignTop="@id/button1"
android:layout_marginLeft="50dip"
android:text="aaa"/>
android:id="@+id/button1_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1_1"
android:layout_alignTop="@id/button1_1"
android:layout_marginLeft="50dip"
android:text="aaaa"/>
android:id="@+id/button1_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button1"
android:layout_marginLeft="25dip"
android:layout_marginTop="25dip"
android:text="b"/>
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginTop="25dip"
android:text="c" />