I have BaseAdapter Class for ListView in my Custom ListView Project. Now I I have TextView, and Tow Image Buttons(Edit and Delete) are in my listView row. When I am fire delete query From GetView() And call notifyDataSetChanged(); but nothing happening there. Please See below code :
public View getView(final int position, View convertView, ViewGroup parentView) {
ViewHolder holder ;
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.local_jobs_list_row , null);
holder.job_name = (TextView) convertView.findViewById(R.id.txt_job_name);
holder.img_edit = (ImageButton) convertView.findViewById(R.id.icon_edit_job);
holder.img_delete = (ImageButton) convertView.findViewById(R.id.icon_delete_job);
convertView.setTag(holder);
holder.img_delete.setTag(itemDetailsrrayList.get(position).getLocal_job_id());
holder.img_delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
db.open();
db.deleteLocalJob(String.valueOf(v.getTag()));
db.close();
notifyDataSetChanged();
}
});
holder.job_name.setText(itemDetailsrrayList.get(position).getLocal_job_name());
return convertView;
}
Here notifyDatasetChanged() not working ......please anybody tell me where i am making mistack ?
notifyDatasetChanged() will work when you do a modification in itemDetailsrrayList. You are doing only Database operation not removing item from ArrayList.Remove the item from ArrayList as well. It will work.
Make sure BaseAdapter methods
registerDataSetObserver(DataSetObserver observer)
unregisterDataSetObserver(DataSetObserver observer)
are not overridden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With