开发者

Multi-line Listview in Android [duplicate]

This question already has answers here: Custom Adapter for List View (13 answers) Closed 7 years ago.

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开发者_JAVA技巧 ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_multiple_choice, items);
        setListAdapter(theList);

Is there any way to do this?


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜