Android - Texte déroulant de sélection/de Spinner ne montre pas

Je suis à l'aide de cet exemple de code pour remplir la casserole. Les données sont lues à partir de la base de données. La sélection s'affiche correctement - dans ce cas, il montre "Vert" et "Rouge".

    Spinner spinnerColor = (Spinner) findViewById(R.id.spinnertProfile);

    mProfileDbHelper = new ProfileDbAdapter(this);
    mProfileDbHelper.open();

    Cursor profilesCursor = mProfileDbHelper.fetchAllProfiles();
    startManagingCursor(profilesCursor);

    //Create an array to specify the fields we want to display in the list
    String[] from = new String[] { ProfileDbAdapter.COL_PROFILE_TITLE };

    //and an array of the fields we want to bind those fields to
    int[] to = new int[] { R.id.textviewColors };

    //Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter profilesAdapter = new SimpleCursorAdapter(this,
            R.layout.profile_color, profilesCursor, from,
            to);

    spinnerColor.setAdapter(profilesAdapter);

}

Cependant, quand j'ai changé d'utiliser une mise en page différente android.R.de mise en page.simple_spinner_dropdown_item. Le Spinner un Texte disparu.

    //Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter profilesAdapter = new SimpleCursorAdapter(this,
            R.layout.profile_color, profilesCursor, from,
            to);

    profilesAdapter
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinnerColor.setAdapter(profilesAdapter);

Voir des instantanés de sans et avec simple_spinner_dropdown_item ci-dessous:
Android - Texte déroulant de sélection/de Spinner ne montre pas

Tout ce que je peut manquer?

est textviewColors utilisé dans simple_spinner_dropdown_item? J'avais le double de vérifier les fautes de frappe.
Qberticus, je ne suis pas sûr que je comprends ce que vous dites. Je suis un Android newbie 🙂 Le textviewColors est l'ID de la TextView dans le layout/profile_color.xml où profilesAdapter se réfère lorsqu'il instancie comme SimpleCursorAdapter. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="" android:id="@+id/textviewColors" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> </LinearLayout>

OriginalL'auteur user370640 | 2010-06-18