讓你定義適配器這樣的,
這裏是佈局custom_items_list.You可以改變佈局accordingly.I我只是張貼的佈局,我現在有。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/headerHeight1"
android:gravity="center"
android:padding="5dp" >
<TextView
android:id="@+id/more_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/viewSpace1"
android:textColor="#000000"
android:textSize="@dimen/titlebar_textSize"
tools:ignore="HardcodedText" />
<TextView
android:textSize="@dimen/titlebar_textSize"
android:textColor="#000000"
android:id="@+id/itemPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<View
android:layout_height="0.5dip"
android:background="#000000"
android:layout_width="fill_parent"
android:layout_marginLeft="@dimen/viewSpace3"
android:layout_marginRight="@dimen/viewSpace3"/>
</LinearLayout>
在您的主要活動,
ArrayList<HashMap<String, String>> detailss = new ArrayList<HashMap<String, String>>();
ItemList=(ListView) findViewById(R.id.listViewItems);
HashMap<String, String> map = new HashMap<String, String>();
map.put("itemId", "1");
map.put("itemName", "Name");
map.put("itemPrice", "120");
detailss.add(map);
adapter = new CustomItemsList(this, detailss);
ItemList.setAdapter(adapter);
不知道你要問這裏。您可以將您的代碼發佈到目前爲止所取得的成就嗎?您的自定義佈局等 – 2015-04-02 06:50:48
請嘗試以下鏈接http://androidexample.com/How_To_Create_A_Custom_Listview_-_Android_Example/index.php?view=article_discription&aid=67&aaid=9 – 2015-04-02 06:51:56
嘗試任何基本的自定義列表視圖示例,您將找到答案 例如:http ://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/ – 2015-04-02 06:58:48