Im using a SimpleCursorAdapter to fill the list inside an AlertDialog. The SimpleCursorAdapter uses the android.R.layout.simple_list_item_1 layout.
The dialog pops up. The list has correct amount of entries. But nothing is displayed. If I choose one entry, the selected entry ist highlighted and the text from my cursor is displayed.
The selection chooses the right entry.
Here is my code:
Intent dataIntent = new Intent();
dataIntent.setData(Ereignistypen.CONTENT_URI);
Cursor cursor = managedQuery(dataIntent.getData(), new String[] {
Ereignistypen._ID, // 0
Ereignistypen.NAME // 1
}, null, null, Ereignistypen.ORDERBY);
SimpleCursorAdapter typAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor,
new String[] { Ereignistypen.NAME }, new int[] { android.R.id.text1 });
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.ereignistyp);
builder.setAdapter(typAdapter, this);
AlertDialog typPicker = builder.create();
typPicker.show();
What do I wrong?
I checked Android SimpleCursorAdapter results not displaying in AlertDialog. But it was little helpfull to me.
EDIT:
If I switch to android.R.layout.simple_spinner_item the list is displayed in an ugly style. But the entries are visible.
The text is there but is not visible because of style.
I made my own layout with slightly different styles.
This is the original simple_list_item_1 out of sdk sources.
I extended to following:
Setting the textcolor explicit solved the problem.
I’m not shure which layout is used if I set the items with AlertDialog.builder.setItem