问题描述
林新到Android。我曾试图建立拥有2微调的应用程序...我以前去深,我的应用程序很少疑虑清楚..
Im new to android. i have tried to built an application which has 2 spinner...i have few doubts to clear before going deep to my application..
请我的问题给出简短的答案...
please give brief answer to my question...
- 是有可能有2纺纱厂在一个视图?
- 我可以添加
setOnItemSelectedListener(本)
为? - 如果是的,我怎么能知道哪个选项被选中,同时在纺纱?如
spinner.getSelectedItemPosition();
同时在纺织
- is it possible to have 2 spinners in one view?
- can i add
setOnItemSelectedListener(this)
for both? - if yes, how could i know which option is selected on both the spinners? like
spinner.getSelectedItemPosition();
on both the spinners?
等待乌拉圭回合宝贵的答复。参考材料也AP preciable
waiting for ur valuable replies. reference materials are also appreciable
推荐答案
是的,你可以有多个微调的,可以通过单一的监听器进行管理,也可以有单独的侦听器为每个。
Yes, you can have multiple spinner's that can be managed by single listener or you can have seperate Listener for each.
有关单监听器,你可以做这样的事情,
For Single Listener you can do something like this,
设置监听器
spinner1.setOnItemSelectedListener(this);
spinner2.setOnItemSelectedListener(this);
然后你可以用 onItemSelected
来得到执行与微调的动作。
Then you can use onItemSelected
to get perform the action related to the spinner's.
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position,long arg3)
{
int id = parent.getId();
switch (id)
{
case R.id.spinner1:
// your stuff here
break;
case R.id.spinner2:
// your stuff here
break;
}
这篇关于多次微调的简单质疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!