0

How to change the text color of default spinner. I need to set color grey but by default it shows Black.

Please help me out. Thanks.

2 Answers2

1

Override the adapter to change spinner text color :-

 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;

        }
    };
Yugesh
  • 4,030
  • 9
  • 57
  • 97
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);
Naveen Tamrakar
  • 3,349
  • 1
  • 19
  • 28