动态的机器人如何获取增值微调 [英] Android How to retrieve value of Dynamically added Spinner

查看:153
本文介绍了动态的机器人如何获取增值微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动态通过解析XML文件添加在我的应用程序中的纱厂。

I am dynamically adding the Spinners in my application by parsing the XML file.

我已经做使用下面的code

I have done using the below code

List<Spinner> allspin = new ArrayList<Spinner>();
Spinner spin = new Spinner(getParent());
allspin.add(spin);
spin.setLayoutParams(new LayoutParams(
     LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getParent(),
        android.R.layout.simple_spinner_item, selectval);
                    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(adapter);

纱厂都显示正常,但我不知道如何检索选择微调的价值。如果有一个微调,我可以retieve,但也有多个,我应该怎么办?

Spinners are displayed correctly but i don't know how to retrieve the value of selected spinner. If there is one spinner i can retieve, but there are multiple how should i do?

推荐答案

您可以微调从您的ArrayList中像这样的参考:

You can get the reference of the spinner from your arraylist like this :

Spinner spn = allspin.get(index);

之后,你可以通过简单地调用获得所选择的项目:

After that you can get the selected item by simply calling:

spn.getSelectedItemPosition();

这篇关于动态的机器人如何获取增值微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆