spinner get item text
Spinner spinner = (Spinner)findViewById(R.id.spinner);
String text = spinner.getSelectedItem().toString();
spinner get item text
Spinner spinner = (Spinner)findViewById(R.id.spinner);
String text = spinner.getSelectedItem().toString();
how to access a spinner from another activity in android
First save the position of selected data from spinner in a String variable,
int positionOfSelectedDataFromSpinner;
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
positionOfSelectedDataFromSpinner= position;
}
Then on button click send intent to Another activity with putExtra
Intent i = new Intent (this, activity2.class);
i.putExtra("position", positionOfSelectedDataFromSpinner);
startActivity(i);
get int from getIntent in another activity
Intent intent = getIntent();
int positionToShowToSpinner = intent.getStringExtra("position");
then set the position to spinner
spinner.setSelection(positionToShowToSpinner);
I think this my solve your problem.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us