我使用列表視圖如下Android的自定義佈局的ListView
String[] Shows = new String[] { "Dexter", "Breaking Bad", "The Big Bang Theory", "Leverage"};
ListView tv_show_list = (ListView) view_tvshowAddNew.findViewById(R.id.lv_tv_show_list);
ArrayAdapter<String> showNameAdapter = new ArrayAdapter<String>(getActivity(), R.layout.tv_show_each_show_name, Shows);
tv_show_list.setAdapter(showNameAdapter);
現在我tv_show_each_show_name XML是像下面
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="58dp"
android:background="@drawable/ic_launcher"
>
</TextView>
我想現在要做的是讓每一個顯示相關聯的名字一張圖片,也許把它放在地圖上,如: -
Map mMap = new HashMap();
mMap.put("Dexter", "imageDexter.png");
mMap.put("Breaking Bad", "imageDexter.png");
並加載列表視圖時,我會顯示t他從該地圖命名並設置相關的圖像背景,從該地圖獲取圖像名稱並從可繪製文件夾中加載。
如何做到這一點?
跳躍像佈局如下
我相信這是相當中肯: http://stackoverflow.com/questions/8166497/custom-adapter-for-list-view – rynojvr