1

Use android.R.layout.simple_spinner_item. I use this class java:

   final Spinner s = (Spinner) findViewById(R.id.spinner1);
      ArrayAdapter adapter = ArrayAdapter.createFromResource(
      this, R.array.seleziona, android.R.layout.simple_spinner_item);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            s.setAdapter(
                      new NothingSelectedSpinnerAdapter(
                            adapter,
                            R.drawable.contact_spinner_row_nothing_selected,
                            //                  R.layout.contact_spinner_nothing_selected_dropdown, // Optional
                            this));
            s.setPrompt("Seleziona");




    s.setOnItemSelectedListener(new OnItemSelectedListener() {

    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

        String voceSelezionata = (String) s.getSelectedItem();

    }

    public void onNothingSelected(AdapterView<?> arg0) {

    }
    });

}

By default, the color is blue. How change only color in red?`

user3589252
  • 11
  • 1
  • 2

1 Answers1

1

You mean textcolor?

Make custom xml file for your spinner item.

spinner_item.xml:

give your customized color and size to text in this file.

<?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="wrap_content"
    android:textSize="20dip"
    android:gravity="left"  
    android:textColor="#FF0000"         
    android:padding="5dip"
    />

Now use this file to show your spinner items like:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item,list);

You don't need to set drop down resource.it will take spinner_item.xml only to show your items in spinner.

extmkv
  • 1,991
  • 1
  • 18
  • 36
  • No,I want to change the color of listview wich compare when click on the spinner. Image exemple: https://www.dropbox.com/s/m6qb15vhhhm3r5b/Screenshot_2014-04-30-15-12-51.png – user3589252 May 02 '14 at 08:39