I am a novice android developer trying to program my first application. I am almost done, but for the last step of the app, I want to take the selection the user made on the previous page from a spinner.
After the user chooses a string from the spinner, they press a button at the button to move to the next page. I retrieved the string from the spinner using getItemAtPosition
, but I don't know how to pass that information to the button method so that I can use intent to pass it to the next activity. I know I could get rid of the button entirely and go to the next activity once the user has selected a string from the spinner, but I don't really want to do that. Here is the code below:
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String text = adapterView.getItemAtPosition(i).toString();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
public void quoteButton(View view){
Intent intent = new Intent(this, DisplayQuoteActivity.class);
startActivity(intent);
}
text
is the string that the user selected and quoteButton
is the button to jump to the next activity but I do not know how to transfer the string text
from the onItemSelected
method to the quoteButton
method.
Thanks for the help.