我试图找到任何关于更改 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>

最佳答案

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

 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;

        }
    };

关于Android 微调弹出文本颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27149739/

10-12 00:23