我有我的ListView
问题不同:列表视图与图像的每个项目
的ListView项XML有一个textarea和ImageView的,从数据库取每个项目,我需要放置一个专用的图像(基于_id)。
现在我有这个代码的工作(但没有图像):
mio_db.openDataBase();
final Cursor data=mio_db.catalogo_prodotti();
final ListView listView1 = (ListView) findViewById(R.id.list_mia_2);
String[] from = new String[] {"prodotto","_id"};
int[] to = new int[] {R.id.nome_prodotto_lista,R.id.freccia_prodotto_lista};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.mia_lista_2, data, from, to);
listView1.setAdapter(adapter);
例如,如果我的_id
4我需要把图像像freccia_4
在R.id.freccia_prodotto_lista
我不不知道该怎么做。我读过关于自定义适配器,但我不明白如何实现它。
任何人都可以帮助我吗?
'SimpleCusorAdapter'构造函数已被弃用。 http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html更好地使用自定义适配器。以下示例http://www.androidchennai.blogspot.in/2012/03/android-listview-example.html –
问题是,教程不使用游标来做到这一点... – Zak
下面的教程将有助于您的需求** [自定义列表视图](http://www.ezzylearning.com/tutorial.aspx?tid=1763429)和[this](http://android-er.blogspot.co.uk/2010/06/ custom-arrayadapter -with-with-different.html)**视频 - [youtubeVideo](http://www.youtube.com/watch?v=LjAlNfa6obU)希望它有帮助 – GoCrazy