public class _alefon_radio extends Activity implements OnCheckedChangeListener {
/** Called when the activity is first created. */
private TextView tx;
private RadioGroup rg;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tx = (TextView) findViewById(R.id.tvv);
rg = (RadioGroup) findViewById(R.id.rgroup);
rg.setOnCheckedChangeListener(this);
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
// for R.id.option1
case R.id.option1:
tx.setText("option one is checked");
//tx.setVisibility(0); //visible
break;
default:
tx.setText("");
//tx.setVisibility(4); //invisible
}
}
}
排外:
<?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"
>
<TextView
android:id="@+id/tvv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
/>
<RadioGroup
android:id="@+id/rgroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:id="@+id/option1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 1" />
<RadioButton
android:id="@+id/option2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 2" />
<RadioButton
android:id="@+id/option3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 3" />
</RadioGroup>
</LinearLayout>
我使用了it本案文,而不是制造反弹/无形的,但如果你愿意使用这种方式,我也包含对等控制(合并)。
我希望这是你所期待的。
好的桶