0

I have used simple cursor adapter to set adapter for spinner as i have used sqlite databse. but i am not able to customize the font color of the spinner,

Image

Here is the Url of the my spinner has dark red background i want to change text color to white using simple cursor adapter with spinner android

code :

    Cursor cursor = dbAdapter.getAllData();

    if(cursor.getCount()>0){
    String[] from = new String[]{"columm_name"};
    // create an array of the display item we want to bind our data to
    int[] to = new int[]{android.R.id.text1};
    SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cursor, from, to);

    mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerName.setAdapter(mAdapter);
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
ud_an
  • 4,939
  • 4
  • 27
  • 43
  • I hope the link can help you, http://stackoverflow.com/questions/5836254/android-change-text-color-of-items-in-spinner Regards – ShawnWang Aug 02 '11 at 05:01
  • that is using ArrayAdapter i am able to change using ArrayAdapter but not using the SimpleCusrsor Adapter. when i use my own textview in simple cursor adapter it don't show any text – ud_an Aug 02 '11 at 05:04

1 Answers1

5

solution to my question hope it will help others.

<?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" android:textColor="#ffffff"/>

just give this textview android simple cursor adapter in place of android.R.layout.simple_spinner_item

ud_an
  • 4,939
  • 4
  • 27
  • 43