如何改变一个微调的形象 [英] How to change image of a spinner
本文介绍了如何改变一个微调的形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我们看到一个喷丝它看起来像一个TextView和与图像到的TextView的右侧。在摩托罗拉里程碑的形象是向下的箭头,而在三星GALAXY ACE这是正确的方向。我可以用下面的code设置背景图片为微调。但我DONOT想改变的背景图像。我想改变这种形象。如何设置一个微调的这种形象。
微调SP1 =(微调)findViewById(R.id.spnContactTypes1);
sp1.setBackgroundResource(R.drawable.icon);
解决方案
您需要变化微调选择
这是与完成的:
<微调机器人:ID =@ + ID / my_spinner
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:drawSelectorOnTop =真
机器人:spinnerSelector =@可绘制/ myspinner_selector>
和 myspinner_selector.xml
:
< XML版本=1.0编码=UTF-8&GT?;
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目安卓state_first =真
机器人:state_dropdown_showing =真
机器人:可绘制=@可绘制/ btn_dropdown_down/>
<! - 其他国家... - >
< /选择器>
If we see a spinner it looks like a textview and with an image to the right of textview. In Motorola milestone that image is down arrow while in Samsung galaxy ace it is right arrow. I can set background image to a spinner using the following code. But I donot want to change the background image. I want to change that image. How to set that image of a spinner.
Spinner sp1 = (Spinner) findViewById(R.id.spnContactTypes1);
sp1.setBackgroundResource(R.drawable.icon);
解决方案
You want to change the spinner selector
This is done with:
<Spinner android:id="@+id/my_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:spinnerSelector="@drawable/myspinner_selector">
and in myspinner_selector.xml
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_first="true"
android:state_dropdown_showing="true"
android:drawable="@drawable/btn_dropdown_down"/>
<!-- other states ... -->
</selector>
这篇关于如何改变一个微调的形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文