Punith K Punith K - 19 days ago 7
Android Question

How to create multiple spinners in android and pass that spinner data to another activity(same)

I wanted to select data from two spinners and pass that data to another activity (Already i can able to pass data from single spinner), but in my project i have 2 spinners called, select Department and select Semester. I want to know how to select data from both spinners and pass it to same activity (Register Activity in my project). Data selected from both spinners must be passed to same activity.

Answer

Get the selected items into variables and send them as following with the Intent

Intent intent = new Intent(this, NextActivity.class);
intent.putextra("SpinnerName1",SpinnerVal1);
intent.putextra("SpinnerName2",SpinnerVal2);
startActivity(intent);

In your next activity you can access them

String value1= getIntent().getStringExtra("SpinnerName1");
String value2= getIntent().getStringExtra("SpinnerName2");