В упражнении вы хотите радио кнопки, а не TabActivty .. попробуйте что-то вроде этого ниже.NB: обратите внимание на радиокнопки. Перед публикацией я скопировал некоторый код для управления местоположением.Но логика radioButton даст вам то, что вы хотите.
public class Distribute extends Activity implements OnClickListener {
@SuppressWarnings("unused")
private static final String DEBUG_FLAG = "DEBUG_FLAG";
private static final String SAVE_PREFS = "save_prefs";
private static RadioButton mUserTypeRadioButton1;
private static RadioButton mUserTypeRadioButton2;
private static RadioButton mUserTypeRadioButton3;
private static RadioButton mUserTypeRadioButton4;
private static CheckBox mSavePrefs;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("Distribution");
setContentView(R.drawable.configup);
Button button = (Button)findViewById(R.id.btn_configup1);
mUserTypeRadioButton1 = (RadioButton) findViewById(R.id.rb_configup1);
mUserTypeRadioButton2 = (RadioButton) findViewById(R.id.rb_configup2);
mUserTypeRadioButton3 = (RadioButton) findViewById(R.id.rb_configup3);
mUserTypeRadioButton4 = (RadioButton) findViewById(R.id.rb_configup4);
mSavePrefs = (CheckBox) findViewById(R.id.cb_config1);
button.setOnClickListener(this);
}
public void onClick(View v) {
Intent i = new Intent();
Bundle extras = new Bundle();
int userType = 0;
int savePrefs = 0;
//i.putExtra("passLoc", currLoc);
i.setClass(getApplicationContext(), Clevel.class);
i.putExtras(extras);
if (mUserTypeRadioButton1.isChecked()) {
userType = 1;
}
else if (mUserTypeRadioButton2.isChecked()) {
userType = 2;
}
else if (mUserTypeRadioButton3.isChecked()) {
userType = 3;
}
else if (mUserTypeRadioButton4.isChecked()) {
userType = 4;
}
if (mSavePrefs.isChecked()) {
savePrefs = 1;
}
else {
savePrefs = 0;
}
if (userType == 4){
Toast.makeText(this, "Ad-Hoc Reporting is not Yet Implemented", 5).show();
i.putExtra("SetTab", 1);
}
else if (userType == 0){
Toast.makeText(this, "Please Select a Report Group", 5).show();
i.putExtra("SetTab", 1);
}
else {
i.putExtra("ds", userType);
i.putExtra("prefs", savePrefs);
i.putExtra("SetTab", 2);
}
startActivity(i);
}
}
В вашем TabHost вам понадобится что-то подобное для управления Intent / Bundle
/**
* Distribute TabHost--------------------------------
*/
intent = new Intent().setClass(this, Distribute.class);
if(mTab == 1){
mPos = extras.getInt("lvPos");
mPrefs = extras.getInt("prefs");
intent.putExtra("lvPos", mPos);
intent.putExtra("prefs", mPrefs);
}
spec = tabHost.newTabSpec("Config").setIndicator("Distribute-It!",
res.getDrawable(R.drawable.gixconfig))
.setContent(intent);
tabHost.addTab(spec);
и необходимым XML ..Для начала, вам нужно обернуть это в свой XML, чтобы экран, на котором вы хотели, чтобы радио-кнопки отображались
<RadioGroup
android:id="@+id/rg_configup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
>
<RadioButton
android:id="@+id/rb_configup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sales"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
>
</RadioButton>
<RadioButton
android:id="@+id/rb_configup2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Regional"
android:layout_above="@+id/rb_configup1"
android:layout_alignLeft="@+id/rb_configup1"
>
</RadioButton>
<RadioButton
android:id="@+id/rb_configup3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Global"
android:layout_above="@+id/rb_configup2"
android:layout_alignLeft="@+id/rb_configup1"
>
</RadioButton>
<RadioButton
android:id="@+id/rb_configup4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ad-hoc"
android:layout_above="@+id/rb_configup3"
android:layout_alignLeft="@+id/rb_configup1"
>
</RadioButton>
</RadioGroup>