Android微调器弹出文本颜色

时间:2014-11-26 12:51:34

标签: android

我试图找到有关更改Spinner弹出文本颜色的任何文档,但我找不到。我可以更改微调文本颜色,但我想更改弹出文本颜色,我不能这样做。

    final ArrayList<String> list = new ArrayList<String> ();
    String panels[] = G.config_smsNumber.split ( "," );
    /* Fill Spinner with panel phone numbers */
    for( int i=0; i <= panels.length -1 ; i++){
        list.add(panels[i]);
    }
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
            ( getApplication (), R.layout.spinner_item, list );

layout.spinner_item:

<?xml version="1.0" encoding="utf-8"?>

<TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textColor="#000000"
        android:text="eeeeee" android:gravity="center|left" android:paddingLeft="5dp"/>

更改微调背景:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
            android:opacity="transparent">
    <item
            android:state_pressed="true">
        <shape android:shape="rectangle">
            <solid android:color="#fe8010"/>
        </shape>
    </item>
    <item
            android:state_selected="true">
        <shape android:shape="rectangle">
            <solid android:color="#cccccc"/>
            <corners
                    android:bottomRightRadius="5dp"
                    android:bottomLeftRadius="5dp"
                    android:topLeftRadius="5dp"
                    android:topRightRadius="5dp"/>
        </shape>
    </item>
    <item android:drawable="@drawable/spinner_ab_default_cms"></item>
</layer-list>

1 个答案:

答案 0 :(得分:5)

覆盖适配器以更改微调文本颜色: -

 your_adpter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_dropdown_item, array){

        @Override
        public View getDropDownView(int position, View convertView,ViewGroup parent) {
            // TODO Auto-generated method stub

            View view = super.getView(position, convertView, parent);

             TextView text = (TextView)view.findViewById(android.R.id.text1);
             text.setTextColor(Color.BLACK);  

             return view;

        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub

            View view = super.getView(position, convertView, parent);

             TextView text = (TextView)view.findViewById(android.R.id.text1);
             text.setTextColor(Color.BLACK);  

             return view;

        }
    };