Use android.R.layout.simple_list_item_1 with a light theme

I found out that when using android:entries with a ListView it uses android.R.layout.simple_list_item_1 as the layout for the list item and android.R.id.text1 as the TextView identifier inside this layout. Please correct me if I am wrong.

Knowing this, I wanted to create my own adapter, but use the same layout resources to ensure interface consistency with the platform. So I tried the following:

 mAdapter = new SimpleCursorAdapter( getApplicationContext(), android.R.layout.simple_list_item_1, mSites, new String[] { SitesDatabase.KEY_SITE }, new int[] { android.R.id.text1 } ); 

Unfortunately, because I use a light theme (I have android:theme="@android:style/Theme.Light" in my <application> ), the list items are displayed with white text, which makes them unreadable.

However, when using android:entries to specify a static list of elements, elements are displayed correctly, with black text.

What am I doing wrong? How to make a dynamic adapter use a standard layout, but work with a light theme?

+10
android listview themes
Jun 08 '10 at 21:33
source share
1 answer

Please correct me if I am wrong.

You are at least mistaken. It uses com.android.internal.R.layout.simple_list_item_1 . Although it is almost identical to android.R.layout.simple_list_item_1 , it can be different.

Also, never use getApplicationContext() . Just use Activity as Context . See if that helps.

+15
Jun 08 '10 at 21:47
source share
— -



All Articles