final RadioGroup radioGroup1 = (RadioGroup) findViewById(R.id.radiogroup);
final TextView tv=(TextView) findViewById(R.id.textView1);
Button mSubmitButton = (Button) findViewById(R.id.btnSubmit);
relation.setOnItemSelectedListener(new CustomOnItemSelectedListener());
radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
String text1;
@Override
public void onCheckedChanged(RadioGroup group, int checkedId)
{
RadioButton checkedRadioButton = (RadioButton) findViewById(checkedId);
text1 = checkedRadioButton.getText().toString();
Toast.makeText(getApplicationContext(), text1, Toast.LENGTH_SHORT).show();
}
});
mSubmitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String fName = first_name.getText().toString();
String re_lation = (String) relation.getSelectedItem();
String add_ress = address.getText().toString();
}
在我的 Onclick 函数中,我想从 onCheckedChanged 获取 text1 值。如何在我的 onclick 函数中获取 text1 值?