开发者

Specific Listview -> Android

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

Th开发者_JS百科anks for answers


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
            }
        );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜