Using custom ListView items
Using a list view, we can entirely customize the way each item looks. We don't have to stick to a simple template, but rather provide a much more detailed view.
How to do it...
All we need to do in order to create a custom item template is to create a custom layout, either by code or in a layout resource:
First, we create the item template using normal layout files.
For example, we can create a layout named
ListItemLayout.axml
with three content views—an image view and two text views:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="0" /> <LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="fill_parent" android...