我动态通过解析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();