Simple_list_item_2 on Android

after creating some menus with simple_list_item_1(which worked very well) I tried replacing this with simple_list_item_2, but my system throws exceptions ...

Now I am wondering how to create such an entry with two different sizes for my list ... are there any traps for beginners? Can someone please help me solve my (small !?) problem?

My code is as follows:

ListAdapter listAdapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_2, fileNames);
setListAdapter(listAdapter);

My String[] fileNamesstores all lines for display in ascending order (does it matter for functionality ?!)

After an unsuccessful search on some forums, I hope that one of you can give me a useful suggestion.

nice greetings, poeschlorn

+5
source share
1 answer

simple_list_item_2different, not just a TextView contains a TwoLineListItem containing two TextViews. ArrayAdapter will not work here because the constructor you are using expects only a TextView; just look at the constructors . Instead, you will either have to create a custom adapter, or use one that supports it, like SimpleCursorAdapter or (I think) SimpleAdapter. This guy has a somewhat hacky solution that might work for you.

+10
source

All Articles