Need to make a List [closed]

2019-08-11 13:57发布

Need to make a List that each line have Image and data (text)

what is the right way? with list of table row ? or it is possible with ListView?

thanks for your help

标签: android
2条回答
趁早两清
2楼-- · 2019-08-11 14:27

The ListView is the way to go, it will take care of releasing the memory and it will be faster to draw and to process.

You can follow this tutorial in order to build the basic structure. Then modify the list_item.xml file (or however you named it) in order to fit your layout. Then, use a custom adapter, you can extend ArrayAdapter<item>, for example, and there you can build the rows as needed

For example, you can have a RelativeLayout with an ImageView aligned to the left, and the TextView in the right. This layout is going to be reused in every row.

This is a tutorial that you can follow to create it.

If you feel like make it more efficient, watch this video that can help you optimize your ListView.

I hope that helps.

查看更多
做自己的国王
3楼-- · 2019-08-11 14:29

A ListView is the easiest if you don't know the length of the list, and/or you want it scrolling.

If you have a list and you want to control the height (e.g.: 1 page etc), you might not be the best off with a listview, but better take a relative- or linear layout, possibly in a scrollview (but then, if you have a scrollview, you probably stopped at listview ;) )

查看更多
登录 后发表回答