Android的微调不抽签选定的项目 [英] Android spinner dont draw selected item

查看:104
本文介绍了Android的微调不抽签选定的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在它有三个项目的微调

I have a spinner with three items in it

<string-array name="menuitems">
    <item>one</item>
    <item>two</item>
    <item>three</item>
</string-array>

然后,我建立了我的微调像这样

Then I set up my spinner like this

 Spinner spinner = (Spinner) findViewById(R.id.spinner1);
 ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
         R.array.menuitems,  R.layout.spinnerstyle);

 adapter.setDropDownViewResource(R.layout.spinnerdropdownstyle);

 spinner.setAdapter(adapter);

微调器显示这样的

The spinner displays like this

一个

两个

我的问题是这棵摇钱树,我不希望显示所选择的项目,我希望本

My problem is for this spinner I don't want to display the selected item I want this

两个

和很明显,如果两个人只选择了一个和三个会出现在下拉列表。我没有寻找这一点,但不能想出一个办法让我的影响试图改变上选择菜单项数组,但如果我从那里删除的项目不会在选择绘制。我假设有一个相当简单的方法来得到这个影响。

And obviously if two were selected only one and three would appear in the dropdown. I did search for this but couldn't figure out a way to get that affect I tried changing the menuitems array on selection but if I removed the item from there it wouldn't draw it in the selection. I assume there is a fairly easy way to get this affect.

感谢您的帮助。

推荐答案

您可以尝试设置PROMT在XML中一是这样的:

You can try to set the promt in the xml to "One" like this:

<Spinner android:id="@+id/spinnerTest"  
 android:layout_marginLeft="50px"
 android:layout_width="fill_parent"                  
 android:drawSelectorOnTop="true"
 android:layout_marginTop="5dip"
 android:prompt="@string/SelectOne"
 android:layout_marginRight="30px"
 android:layout_height="35px" 
/> 

那你应该重写onItemClick梅索德并设置变量的文本
在没有任何选择。

Then you should override the onItemClick methode and set the text of your variable in "On nothing selected".

这篇关于Android的微调不抽签选定的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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