Tôi có thể biết làm thế nào để làm mới mục ListView sau khi tôi đã loại bỏ một mục danh sách bản đồ trong SimpleAdapter tùy chỉnh?Android: Làm thế nào để làm mới danh sách khi xóa mục trong tùy chỉnh SimpleAdapter
Tôi đã triển khai thành công mục danh sách xóa với list.remove (vị trí), nhưng khi tôi đã cố gọi hàm list.notifyAll() nhưng nó đã cho tôi thông báo lỗi như "java.lang.IllegalMonitorStateException: đối tượng không bị khóa theo chuỗi trước khi thông báoAll() ".
Tôi hy vọng bạn có thể giúp tôi. Đây là mã cho SimpleAdapter tùy chỉnh.
public class DeleteAdapter extends SimpleAdapter {
Context context;
List<? extends Map<String, ?>> list;
int resource;
String[] from;
int[] to;
public FDeleteAdapter(Context context, List<? extends Map<String, ?>> 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;
}
};
Cảm ơn trước sự giúp đỡ của bạn.
nhưng nó cho thấy tôi "không thể làm cho một tham chiếu tĩnh với phương pháp không tĩnh notifyDataSetChanged() từ các loại" ... bạn có thể dạy tôi làm thế nào để giải quyết nó? – user1082138
Sử dụng 'DeleteAdapter.this.notifyDataSetChanged()'. – inazaruk
Có !! nó hoạt động! Cảm ơn bạn đã giúp bạn ^.^ – user1082138