Sending Radio Button Data To Next Activity
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 name and th
Solution 1:
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
Bundleextras= getIntent().getExtras();
if (extras != null) {
String message= extras.getString("radioChosen");
}
Post a Comment for "Sending Radio Button Data To Next Activity"