Android:如何在自定义SimpleAdapter中删除项目时刷新列表

在我删除自定义SimpleAdapter中的地图列表项后,我是否知道如何刷新ListView项?

我已经用list.remove(position)成功实现了删除列表项,但是当我试图调用list.notifyAll()函数但是它给了我一条错误消息,例如“java.lang.IllegalMonitorStateException:对象在notifyAll之前没有被线程锁定()”。

我希望你能帮助我。 这是自定义SimpleAdapter的代码。

public class DeleteAdapter extends SimpleAdapter { Context context; List<? extends Map> list; int resource; String[] from; int[] to; public FDeleteAdapter(Context context, List<? extends Map> data, int resource, String[] from, int[] to) { super(context, data, resource, from, to); this.context = context; this.list = data; this.resource = resource; this.from = from; this.to = to; // TODO Auto-generated constructor stub } @Override public View getView(final int position, View convertView, ViewGroup parent) { final View row = super.getView(position, convertView, parent); final Button delete = (Button) row.findViewById(R.id.deletebut); final TextView title = (TextView) row.findViewById(R.id.label); delete.setOnClickListener(new OnClickListener() { public void onClick(View view) { deleteDialog xdialog = new deleteDialog(context, "Delete? ", position) { @Override public boolean onOkClicked() { list.remove(position); list.notifyAll(); return true; } }; xdialog.show(); } }); return row; } }; 

预先感谢您的帮助。

你应该调用Adapter的notifyDataSetChanged()函数,而不是列表中的notifyAll()

使用

  this.notifyDataSetChange();