开发者

How to color and alignment spinner item on android?

I'm t开发者_高级运维ry to change text color and align item in spinner to center of it how can I do this

here is my code

    String[] li={"1","2","3"};
final Spinner combo = (Spinner)findViewById(R.id.widget30);
ArrayAdapter<String> a = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, li);
combo.setAdapter(a);

Thanks


Use a custom view for that, and specify by calling:

a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

Note that you have to use your own view here: R.id.my_simple_spinner_dropdown_item

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:singleLine="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜