-1

This is my Spinner with Package names of Installed apps as ArrayList. It works fine but the text on spinner items appear white and the text is not visible untill focused. I need to set the item color to black, how can i?

public class AppList extends Activity
{
    private Spinner spinner;
    private ArrayList results = new ArrayList();


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState);
        setContentView(R.layout.main);


        spinner = (Spinner)findViewById(R.id.Button);


        PackageManager pm = AppList.this.getPackageManager();
        Intent intent = new Intent( Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        List list = pm.queryIntentActivities(intent,
        PackageManager.PERMISSION_GRANTED);


        for (ResolveInfo rInfo : list)
        {       results.add(rInfo.activityInfo.packageName.toString());
        }

       spinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, results));
}}
Emm Jay
  • 360
  • 2
  • 20

4 Answers4

2
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, array);
    adaptersetDropDownViewResource(R.layout.your_layout);
    spinner.setAdapter(adapter);

Make a layout xml with only textview:

<?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="match_parent"
android:textcolor="@android:color/black"/>
berserk
  • 2,690
  • 3
  • 32
  • 63
0

Extend the adapter, and customize the view in getView and getDropdownView.

yedidyak
  • 1,964
  • 13
  • 26
0

Edit your simple_list_item_1.xml file

Add this your textview;

 android:textColor="#000000"
mehmetakifalp
  • 445
  • 5
  • 16
0
    ArrayAdapter<String> adap = new     ArrayAdapter<String>     (this,
android.R.layout.simple_
spinner_item, your_array );
    adap.setDropDownViewResource(R.layout.row);
        spinner.setAdapter(adap);

Now Customize the text in row.xml