This is my code in first activity:
Button GoToNewActivity = (Button)findViewById(R.id.send);
GoToNewActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String str = null;
boolean checked = ((RadioButton) v).isChecked();
// Check which radio button was clicked
switch(v.getId()) {
case R.id.radioMale:
if (checked)
str = "Male";
break;
case R.id.radioFemale:
if (checked)
str = "Female";
break;
}
EditText editText = (EditText) findViewById(R.id.edit_text);
String plateNumberEdited = editText.getText().toString();
Intent intent = new Intent(Index.this, DVLAresult.class);
Bundle extras = new Bundle();
extras.putString("dvlaNumber", plateNumberEdited);
extras.putString("radioChosen", str);
intent.putExtras(extras);
startActivity(intent);
}
});
This is my first activity XML :
android:id="@+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="male"/>
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="female"/>
And this is how I try to get value from first activity and use us in second:
Bundle extras = getIntent().getExtras();
String message= extras.getString("radioChosen");
Question is, I would like to use values from first activity like values from text and from selected radio choice, and by using intent use this values in second activity.