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
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
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 extendArrayAdapter<item>
, for example, and there you can build the rows as neededFor example, you can have a
RelativeLayout
with anImageView
aligned to the left, and theTextView
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.
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 ;) )