I\'m trying to allow the user to enter their Name, and click on one of three radio buttons, and click on a submit button. And on the next activity, it will display their nam
- Use switch
to get the Radio button selected.
switch (types.getCheckedRadioButtonId()) {
case R.id.sit_down:
intent.putExtra(SIT_DOWN, "sitdown");
break;
case R.id.take_out:
intent.putExtra(TAKE_OUT, "takeout");
break;
}
- Now just do the startActivity(intent);
String str; // store the text corresponding to the RadioButton which is clicked
switch(view.getId()) {
case R.id.radioButton1:
if (checked)
str = "button1Text";
break;
case R.id.radioButton2:
if (checked) str = "button2Text";
break;
case R.id.radioButton3:
if (checked) str = "button3Text";
break;
}
Intent intent = new Intent(this, WinderDTActivity.class);
intent.putExtra("radioChosen", str); // pass "str" to the next Activity
EDIT : To recieve the data in the next activity, use
Bundle extras = getIntent().getExtras();
if (extras != null) {
String message= extras.getString("radioChosen");
}