我想读取'empname'和'地点'从sqlite数据库和列表到列表视图 我试过给定的代码,但代码显示错误'不可访问代码“可以帮助我找出问题。从sqlite数据库读取数据,并通过哈希映射添加到列表视图
public void listEmps()
{
this.myList.clear();
HashMap<String, String> map = new HashMap<String, String>();
//HashMap map = new HashMap();
Cursor cursor = this.dbAdapter.ListEmp();
int i;
if((cursor !=null)&&(cursor.getCount()>0))
{
cursor.moveToFirst();
i=0;
if(i>cursor.getCount())
{
cursor.close();
myAdapter = new SimpleAdapter(this, myList, R.layout.listadapter, new String[]{"name","place"},
new int[]{R.id.textViewName,R.id.textViewPlace});
this.lvEmp.setAdapter(myAdapter);
this.myAdapter.notifyDataSetChanged();
}
}
while(true)
{
return;
map.put("name", cursor.getString(cursor.getColumnIndex("EmpName")));
map.put("place", cursor.getString(cursor.getColumnIndex("place")));
this.myList.add(map);
map = new HashMap();
if (!cursor.isLast())
cursor.moveToNext();
i++;
break;
cursor.close();
}
}
我在while循环结束时给出了返回值。仍然存在问题..如何解决它? – 2013-03-12 11:57:36
然后请更新您的问题... – 2013-03-12 12:06:52