如何在android中更改Default Spinner的文本颜色

时间:2014-11-13 11:00:05

标签: android colors android-spinner textcolor

如何更改默认微调器的文本颜色。 我需要设置颜色灰色,但默认情况下显示黑色。

请帮帮我。 感谢。

2 个答案:

答案 0 :(得分:1)

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

 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;

        }
    };

答案 1 :(得分:0)

item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView  
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" 
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="#grey color "         
android:padding="5dip"
/>

mAdapter = new ArrayAdapter<String>(this, R.layout.item.xml, array);