Я хочу, чтобы, если бы я выбрал один из своих RadioButton, он показывал String в другом упражнении, как это сделать? это застряло в моей учебе для моей школы, если у вас есть лучший способ, который может мне помочь, в другой сети, всегда использующей Toast, например RadioButton, который не может помочь мне полностью
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dateFormatter = new SimpleDateFormat ("dd-MM-yyyy", Locale.US);
tvDataResult = (TextView) findViewById(R.id.tvSelectedDate);
btDataPicker = (Button) findViewById(R.id.btndate);
btDataPicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDateDialog();
}
});
Spinner spinner = findViewById(R.id.planets_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.planets_array,android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
final EditText edtNama = (EditText)findViewById(R.id.etNama);
final EditText edtNim =(EditText)findViewById(R.id.etNim);
tvDataResult = (TextView)findViewById(R.id.tvSelectedDate);
Button button = (Button)findViewById(R.id.btnTampilkan);
final RadioGroup rbg = (RadioGroup)findViewById(R.id.rgroup);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String nama = edtNama.getText().toString();
String nim = edtNim.getText().toString();
String date = tvDataResult.getText().toString();
int selectedId = rbg.getCheckedRadioButtonId();
rblaki=(RadioButton)findViewById(selectedId);
rbcewe=(RadioButton)findViewById(selectedId);
Intent intent = new Intent(MainActivity.this,ResultActivity.class);
intent.putExtra("Nama",nama);
intent.putExtra("NIM",nim);
intent.putExtra("tanggal",date);
startActivity(intent);
}
});
}
Это мой XML. я только показываю это
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jenis Kelamin"
android:textSize="17dp" />
<RadioGroup
android:id="@+id/rgroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rblaki"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Laki-laki" />
<RadioButton
android:id="@+id/rbcewe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perempuan" />
</RadioGroup>
<Button
android:id="@+id/btnTampilkan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TAMPILKAN" />
<Button
android:id="@+id/btnDelete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="DELETE" />
Я хочу быть таким