[英]How to do 2nd Spinner get selected , based on my 1st Spinner selection?
I am using Two Spinner in my App . 我在我的App中使用Two Spinner。 1st Spinner is array of STATE, 2nd Spinner is array of COUNTRY. 第一个微调器是STATE的数组,第二个微调器是COUNTRY的数组。 Also i am using Spinner with key-value in easy way, ie : 我也以简单的方式将Spinner与键值一起使用,即:
A - Spinner State: A-微调状态:
i take an Array of states using as [KEY], 我将状态数组用作[KEY],
[]state = {"UP","MP",... ,"OUT SIDE INDIA"};
Also i take an another Array of states using as [value] 我也用[value]作为另一个状态数组
[]state_id = {"111","222",......"999"};
Both the above Array are identical in size. 上面两个数组的大小相同。
B - Spinner Country: B-微调国家/地区:
i take an Array of country using as [KEY], 我以[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 并且我正在获取Spinner所选项目的数据[VALUE],例如
@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] ? 我的问题是,如果我选择1st Spinner [state],如何控制2nd Spinner [country]?
for example , i want to select UP , than 2nd Spinner should be auto select on INDIA as disabled. 例如,我要选择UP,然后应在INDIA上自动选择2nd Spinner为禁用状态。
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); 例如:spinner.setselection(2);
check will be like 检查会像
if(spinner1.getselecteditem==1)
{
spineer2.setselection(2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.