📄 rgactivity.java
字号:
package com.misoo.ex12;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class rgActivity extends Activity implements OnCheckedChangeListener{
private final int WC = RadioGroup.LayoutParams.WRAP_CONTENT;
private RadioGroup rg_layout;
RadioGroup.LayoutParams params;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
rg_layout = new RadioGroup(this);
params = new RadioGroup.LayoutParams(WC, WC);
rg_layout.setOrientation(RadioGroup.VERTICAL);
rg_layout.setLayoutParams(params);
rg_layout.setOnCheckedChangeListener(this);
RadioButton button1 = new RadioButton(this);
button1.setText("Yellow");
button1.setId(1001);
params = new RadioGroup.LayoutParams(WC, WC);
rg_layout.addView(button1,params);
RadioButton button2 = new RadioButton(this);
button2.setText("Blue");
button2.setId(1002);
params = new RadioGroup.LayoutParams(WC, WC);
rg_layout.addView(button2,params);
setContentView(rg_layout);
}
public void onCheckedChanged(RadioGroup arg0, int arg1) {
// TODO Auto-generated method stub
String cc;
if(arg0.getCheckedRadioButtonId() == 1001)
cc = "Y";
else cc = "B";
Bundle bundle = new Bundle();
bundle.putString("DataKey", cc);
Intent mIntent = new Intent();
mIntent.putExtras(bundle);
setResult(RESULT_OK, mIntent);
finish();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -