views:

32

answers:

1

Hi! Does somebody knows how to make similar listview? How to split row? Image: link text

Thanks for answers

A: 

Something like

rows.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <ImageView
        android:id="@+id/icon1"
        android:layout_width="40dip"
        android:layout_height="40dip"
        android:layout_alignParentLeft="true"
        android:src="@drawable/icon"
    />
    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/icon2"
        android:layout_toRightOf="@+id/icon1"
        android:text="Some Text"
    />
    <ImageView
        android:id="@+id/icon2"
        android:layout_width="40dip"
        android:layout_height="40dip"
        android:layout_alignParentRight="true"
        android:src="@drawable/icon"
    />
</RelativeLayout>

Then populate the ListView with your data (depending which Adapter you use, here an example for an SimpleCursorAdapter):

    Cursor c = getContentResolver().query(uri, null, null, null, null, null);
    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this,
            R.layout.row, c, 
            new String[] {
                "icon"
                ,"text"
                ,"icon2"
            }, 
            new int[] {
                R.id.icon1
                ,R.id.text
                ,R.id.icon2
            }
        );
Tseng
I think he's talking about how to have the "A", "B" su-bheader rows, not about the row layouts themselves, although I could be wrong.
mbaird