我想讀取'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