我正在使用以下方式作为列表视图
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");
在加载列表视图时,我将从此地图中显示名称,并设置关联的图像背景,从此地图中获取图像名称并从drawable文件夹中加载它。
怎么做呢?
像下面这样布置布局