I’m trying to code a way to pass the values from two spinners into another activity.
I found examples using the putExtra method online but I’m having trouble implementing it myself (I think I’m just unclear on how it works exactly).
The code I have is (without any values in the putExtra method, because that’s the bit I’m stuck on):
public void addListenerOnButton() {
transportSpinner = (Spinner) findViewById(R.id.transportSpinner);
locationSpinner = (Spinner) findViewById(R.id.locationSpinner);
buttonSubmit = (Button) findViewById(R.id.buttonSubmit);
buttonSubmit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(GetDirections.this.getApplicationContext(), DirectionDisplay.class);
i.putExtra();
GetDirections.this.startActivity(i);
}
});
}
Thanks.
Assuming that your spinners are correctly populated, you can do: