您需要做的是創建一個名爲layout
的custom view
以獲取列表項目。
以下代碼將創建一個您選擇的列表項。根據您的要求修改代碼。但你可以從下面的代碼中獲得想法。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/txtItemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:text="Item Name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/txtItemPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignLeft="@+id/txtItemName"
android:text="Item Price" />
<TextView
android:id="@+id/txtRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:text="Rating"
android:textAppearance="?android:attr/textAppearanceSmall" />
在layout
只需複製並粘貼上面的代碼,並切換到Graphical Layout
。你可以看到結果。
以下鏈接可幫助您如何在列表視圖中使用customized layout
。 Custom List1和Custom List2
嘗試使用GridView和使用適配器負載的縮略圖,名稱,價格和評級類http://developer.android.com/guide/topics/ui/layout/ gridview.html – harish
@sudhanshu你想創建列表或網格視圖 – Janmejoy
@Janmejoy'GridView'或'ListView'其實並不重要。我只是想知道如何實現一個GooglePlay列表的應用程序列與2列:) – Sudhanshu