我最近使用ListAdapter創建了一個ListView,並在列表後面應用了一個靜態背景圖像;使用SimpleAdapter對ListView應用背景圖像
String[] teams = getResources().getStringArray(R.array.array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_view, teams));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setBackgroundResource(R.drawable.football_turf_subtle);
lv.setCacheColorHint(0);
我現在正在切換到使用SimpleAdapter在每個列表項目中包含各種項目。
setContentView(R.layout.custom_list_view);
SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.row_view,
new String[] {"pen","price","color"},
new int[] {R.id.text1,R.id.text2, R.id.text3});
populateList();
setListAdapter(adapter);
僅供參考,以上列表中的項目來自我找到的示例。我遇到的問題是我不知道如何應用背景圖像,因爲我以前使用過ListAdapter版本。 (即setBackgroundResource)
任何幫助,將不勝感激!