删除记录后,我无法刷新列表视图。
String str3 = favtitle.get(position);
//position = Integer.parseInt(cur.getString(cur.getColumnIndex("id")));
db.delete("Favorites7","title= '"+str3+"'",null);
//mSchedule.notifyDataSetChanged();
cur.requery();
cur= db.query("Favorites7",
null, null, null, null, null, null);
cur.moveToFirst();
while (cur.isAfterLast() == false) {
//name.append("n" + cur.getString(1));
//mylist.addAll(cur.getString(i));
favtitle.add(cur.getString(1));
favloc.add(cur.getString(3));
favemp.add(cur.getString(2));
lat.add(cur.getString(7));
log.add(cur.getString(8));
//nextScreenData.add(cur.getString(2).toString());
cur.moveToNext();
}
cur.close();
mylist = new ArrayList<HashMap<String,Object>>();
HashMap<String,Object> map = new HashMap<String, Object>();
for(int i=0;i<favtitle.size();i++)
{
map = new HashMap<String, Object>();
map.put("train",favtitle.get(i));
map.put("value",favloc.get(i));
map.put("employer",favemp.get(i));
mylist.add(map);
}
mSchedule.notifyDataSetChanged();
mSchedule = new SimpleAdapter(Favorites.this, mylist, R.layout.listdelete,
new String[] {"train","value","employer"}, new int[] {R.id.dept,R.id.jobloc,R.id.employer});
lv.setAdapter(mSchedule);
lv.setDividerHeight(2);
lv.setCacheColorHint(Color.WHITE);
//cur.requery();
提前完成。
答案 0 :(得分:0)
您可以创建一个新的适配器,然后将其分配给ListView。
答案 1 :(得分:0)
您可以在适配器上调用notifyDataSetChanged(),它会反映对ui的更改
答案 2 :(得分:0)
单击删除按钮时,请执行以下操作: