简体   繁体   English

如何根据我的1st Spinner选择来选择2nd Spinner?

[英]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.

相关问题 如何填充基于第一旋转器的第二旋转器和基于第二旋转器的第三旋转器? - How to populate 2nd spinner based on 1st spinner and 3rd spinner based on 2nd spinner? 如何禁用已在Android中的第一个Spinner中选择的第二个微调器项目 - How to Disable the 2nd Spinner Item Which is selected Already in 1st Spinner in Android 在更改第一微调器值时更改第二微调器值 - changing 2nd spinner values on changing 1st spinner value 由 1st Spinner 创建的 2nd Spinner 应更新 textview - 2nd Spinner which was created by 1st Spinner, should update textview 从数组中填充Spinner1,然后根据第一个Spinner选择为Spinner2选择第二个数组 - Spinner1 populate from array, then select second array for spinner2 based on 1st spinner selection 想要添加一个按钮以根据第一个微调器选择更改意图 - Want to add a button to change the intent based on the 1st spinner selection 当我在第一个微调器中再次选择一个项目时发生错误,然后在第二个微调器中未解析相关数据意味着它没有刷新 - error occur when i select an item again in 1st spinner then the related data do not parsed in 2nd spinner means it does'nt refresh 默认情况下如何在微调框中选择第二个选项? - How to have the 2nd option in a Spinner selected by default? 如何从第二活动到第一活动获取数据 - How to get data from 2nd Activity to 1st Activity 如何根据其他微调器选择过滤微调器? - How to filter spinner based on other spinner selection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM