androidRadioGroup和RadioB…
<RadioGroup
android:id="@+id/myRadioGroup"
android:layout_width="137px"
android:layout_height="216px"
android:orientation="vertical"
android:layout_x="3px"
android:layout_y="54px"
>
<RadioButton
android:id="@+id/myRadioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tr_radio_op1"
/>
<RadioButton
android:id="@+id/myRadioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tr_radio_op2"
/>
</RadioGroup>
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextView1 = (TextView) findViewById(R.id.myTextView);
mRadioGroup1 = (RadioGroup) findViewById(R.id.myRadioGroup);
mRadio1 = (RadioButton) findViewById(R.id.myRadioButton1);
mRadio2 = (RadioButton) findViewById(R.id.myRadioButton2);
mRadioGroup1.setOnCheckedChangeListener(mChangeRadio);
}
private RadioGroup.OnCheckedChangeListener mChangeRadio =
new RadioGroup.OnCheckedChangeListener()
{
@Override public void onCheckedChanged(RadioGroup group, int checkedId)
{
// TODO Auto-generated method stub
if(checkedId==mRadio1.getId())
{
mTextView1.setText(mRadio1.getText());
}
else if(checkedId==mRadio2.getId())
{
mTextView1.setText(mRadio2.getText());
}
}
};
更多相关文章
- android googlemap的location报空指针解决案例
- ndk 历史版本下载
- android滑动删除的一个开源项目SwipeDelMenuLayout的简单使用
- 10个经典的Android开源应用项目
- android短信监听
- 10个经典的Android开源应用项目
- 10个经典的Android开源应用项目
- Android牟利之道(二)--广告平台的介绍
- 10个经典的Android开源应用项目