嗨我之前问过我如何更新列表视图,并得到了使用ArrayAdapter的建议。我现在遵循的事情是问题是关于它更新列表视图,但不是与期望值的某些对象。如何从ArrayList <String[]>获得列表视图中的字符串值?
我的代码是这样的:
Cursor cursor = db.rawQuery("SELECT count(*) FROM BOOKMARKS ", null);
//if any contact found moveToFirst of that contacts or points to 1st email
cursor.moveToFirst();
//checking columns exhist or not
if (cursor.getInt(0) > 0)
{
//get all the contacts from table 'BOOKMARKS'
c = db.rawQuery("SELECT * FROM BOOKMARKS", null);
//get the index of mentiond and required columns
ID = c.getColumnIndex("ID");
booktitl = c.getColumnIndex("Booktiltle");
audiotime=c.getColumnIndex("BookmarkTime");
// Check result.
c.moveToFirst();
if (c != null)
{
// Loop through all Results
do
{
cont = new String[3];
cont[0] = Integer.toString(c.getInt(ID));
cont[1] = c.getString(booktitl);
cont[2] = c.getString(audiotime);
audiobooks.add(cont);
}
while(c.moveToNext());
c.close();
db.close();//close db resources
ArrayAdapter<String[]> arrayAdapter1=new ArrayAdapter<String[]>(this, R.layout.row3, R.id.itemr1,audiobooks);
lv.setAdapter(arrayAdapter1);
我要如何在列表视图的字符串值实际上是从数据库中获取并存储到Arraylist.At目前,我显示在列表视图,但我的一些对象值的值?想要显示“有声读物”所拥有的内容。请帮我解决它。
看看这个伟大的深入教程上ListView和ListActivities:http://www.vogella.com/articles/AndroidListView/article.html –