Punith K
Punith K

Reputation: 666

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.

Upvotes: 2

Views: 916

Answers (1)

Zusee Weekin
Zusee Weekin

Reputation: 1358

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");

Upvotes: 1

Related Questions