Android Studio中设计时,在前端设计了3个RadioButton和1个TextView,想在后台中控制,根据RadioButton的选择不同,TextView中显示不同内容。
但是不管RadioButton怎么西选,TextView都是空白
public class standardpage extends Activity {
@Override
protected void onCreate( Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.standard);
RadioButton radioButton1=(RadioButton)findViewById(R.id.rbutton1);
RadioButton radioButton2=(RadioButton)findViewById(R.id.rbutton2);
RadioButton radioButton3=(RadioButton)findViewById(R.id.rbutton3);
TextView text1=(TextView)findViewById(R.id.textstandard);
if (radioButton1.isSelected())
{
text1.setText("123");
}
if (radioButton2.isSelected())
{
text1.setText("");
}
if (radioButton3.isSelected())
{
text1.setText("");
}
}
}