I am using Two Spinner in my App . 1st Spinner is array of STATE, 2nd Spinner is array of COUNTRY. Also i am using Spinner with key-value in easy way, ie :
A - Spinner State:
i take an Array of states using as [KEY],
[]state = {"UP","MP",... ,"OUT SIDE INDIA"};
Also i take an another Array of states using as [value]
[]state_id = {"111","222",......"999"};
Both the above Array are identical in size.
B - Spinner Country:
i take an Array of country using as [KEY],
[]country = {"USA","UN",... ,"INDIA"};
Also i take an another Array of country using as [value]
[]country_id = {"01","01",......"200"};
Both the above Array are identical in size.
AND i am getting data [VALUE] of selected item of Spinner , like
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String value = state_id[arg2];
}
My Question is , How do i control 2nd Spinner [country] , if i select in 1st Spinner [state] ?
for example , i want to select UP , than 2nd Spinner should be auto select on INDIA as disabled.
make a checque on item selected in first spinner and then according to item selected in 1st spinner set value in second spinner...
eg.spinner.setselection(2);
check will be like
if(spinner1.getselecteditem==1)
{
spineer2.setselection(2);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.