0
私はアンドロイドを新しくしました。ラジオボタンがチェックされているなら、次のページに行きたいです。私は以下のコードを書いたが、うまくいきません。 何が問題ですか?RadioButtonがチェックされている場合、次のページに移動するにはどうすればいいですか? Androidプログラミングで
public class second extends Activity {
public void onCreate (Bundle shamim){
super.onCreate(shamim);
setContentView(R.layout.second);
findViewById(R.id.radioButton1);
RadioButton radioButton1 = (RadioButton) findViewById(R.id.radioButton1);
findViewById(R.id.radioButton2);
RadioButton radioButton2 = (RadioButton)findViewById(R.id.radioButton2);
if (radioButton1.isChecked()) {
startActivity(new Intent(second.this,third.class));
else { (radioButton2.isChecked()) {
startActivity(new Intent(second.this,MyActivity.class));
}
}
}
}
findViewById(R.id.radioButton1)を削除します。およびfindViewById(R.id.radioButton2);これらは必須ではないためです。 –
はradiobutton.setOnCheckedChangeListernerを使用します。 –