1

Hello I have a multi choice listview. I would like to add more than one line of text to each list item. e.g.

List Item 1
Subtext

With subtext being smaller text. etc.

I can't find a solid example of this bar making my own custom list adapter which adds complications for multi select and is sort of over my head. The way I add items currently is

private static final String[] items={"my", "name", "is", "mark", "i", "am", "testing", "lists"};

theList = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_multiple_choice, items);
        setListAdapter(theList);

Is there any way to do this?

Mark Olsen
  • 105
  • 2
  • 6

2 Answers2

2

I was looking for a solution for multi-line ListView and came across this post. The link above no longer works, but I found the following: http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html

The solution here worked just fine for me. If you'e building the list dynamically, as I am, just iterate through your data to build an array of HashMaps.

~Happy coding

agentcurry
  • 2,405
  • 3
  • 17
  • 21
0

You are going to have to create a custom list adapter.

Start by checking out this example and if you still have problems post a new question with your code that you have tried.

Edit: New link. Checkout this question for an example. Custom Adapter for List View

Community
  • 1
  • 1
Corey Sunwold
  • 10,194
  • 6
  • 51
  • 55
  • Seems such a hassle to add a second line. I am able to create a custom listview but the checkboxes are causing me problems as I have to save the checks with the shared preferences. – Mark Olsen Feb 05 '11 at 21:32
  • I agree, it is a bit of a hassle but honestly the second you start going outside the box with layout and functionality in a ListView you are best off just creating a custom adapter. You will gain a lot more control over the ListView which IMO outweighs the cost of adding some annoying boilerplate code to your app. – Corey Sunwold Feb 05 '11 at 21:35
  • @CoreySunwold link doesnt work anymore – shishirmk Apr 24 '13 at 07:58