1
A
回答
1
在this tutorial中,您可以看到如何定義自定義ListView。這應該可以幫助你實現你自己的解決方案。
0
Here's通過重構列表適配器代碼來高效實現複雜列表視圖。
0
下面是代碼,這將幫助ü出在列表視圖中添加圖像
public class ItemsList extends ListActivity {
private ItemsAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.items_list);
this.adapter = new ItemsAdapter(this, R.layout.items_list_item, ItemManager.getLoadedItems());
setListAdapter(this.adapter);
}
private class ItemsAdapter extends ArrayAdapter<Item> {
private Item[] items;
public ItemsAdapter(Context context, int textViewResourceId, Item[] items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.items_list_item, null);
}
Item it = items[position];
if (it != null) {
ImageView iv = (ImageView) v.findViewById(R.id.list_item_image);
if (iv != null) {
iv.setImageDrawable(it.getImage());
}
}
return v;
}
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
this.adapter.getItem(position).click(this.getApplicationContext());
}
}
相關問題
- 1. C#:如何在listview中添加圖像?
- 2. 在ListView列中添加圖像
- 3. 將圖像添加到ListView
- 4. 在ListView中添加視圖
- 5. 在ListView中添加存儲在JSON數組中的圖像 - ReactNative
- 6. 如何通過適配器在Listview中添加圖標圖像?
- 7. Lazy在ListView中加載位圖圖像
- 8. 動態添加圖像到ListView
- 9. 如何將圖像添加到ListView?
- 10. 如何在Android中的自定義ListView中添加圖像?
- 11. 如何添加一個圖像到我的listview在android中?
- 12. 如何在android listview或gridview中動態添加圖像/圖像按鈕
- 13. 在Android ListView中添加箭頭圖片
- 14. 如何添加圖像圖標在android的listview?
- 15. 添加圖像的每個ListView項中出列表視圖
- 16. 在UWP中添加圖像?
- 17. 在ActionListener中添加圖像
- 18. 在awt中添加圖像
- 19. 在java中添加圖像
- 20. 在JApplet中添加圖像
- 21. 添加圖像周圍添加圖像
- 22. 在ListView中添加radioBurton
- 23. C#WinForms - Listview加載圖像
- 24. 在ListView中設置圖像
- 25. 在flex中加載圖像時添加加載器圖像
- 26. 是否可以在ListView頂部添加圖像?
- 27. 向ListView中的行添加不同的圖像
- 28. 從ListView中的數據庫添加圖像
- 29. 如何將圖像添加爲ListView中的子項?
- 30. 如何將圖像添加到ListView從數據庫中填充
看看這裏:http://stackoverflow.com/questions/459729/how-to-display-list-的圖像功能於列表視圖功能於安卓 – slhck 2010-09-02 10:41:36