Complex ListView example with complex data and complex layout of each row?

Viewed 56694

Im pulling a list of product objects from a database call and I want to build a ListView of the data in my activity with a non-scrolling header and footer. Each row will consist of a product thumbnail, some data and a button arranged horizontally. I understand that using the ListView I can inflate each row using a separate layout.

Most of the examples Ive seen using ListView just show a simple array of strings that fill the whole view of the activity, but most real-world examples will be more complex and I can't find any good examples that explain how all these pieces fit together.

Does anyone have any pointers to sample code with a good explanation ?

3 Answers

The easiest way to have a complex row in a ListView is via a SimpleAdapter. There are a number of examples around for that.

To force the ListView to fill the remaining portion of the screen, set the properties as follows:

Use a LinearLayout.

On the list view:

android:layout_height="fill_parent",
android:height="0dp",
android:layout_weight="1"

On all other widgets:

android:layout_height="wrap_content"

Do not set a height or layout_weight

Related