Remove Row From Listview Using Custom BaseAdapter
Hello I have a ListView with CustomBaseAdapter.The listview contents EditText and DeleteButton .Now i want to delete the row on the button click event. I tried adapter.removeViewAt
Solution 1:
Just try for this code,
btnOrImage.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// delete query fire here whatever related to requirements.
mList.remove(position);//you can delete your item here
notifyDataSetChanged();
}
});
This method used for notifyDataSetChanged() refresh to getView() method from your BaseAdapter.
Solution 2:
myHolder.btn_delete.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// remove data from List and call
notifyDataSetChanged(); <-- will remove old data
}
});
Solution 3:
Try this,
holder.delete.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
your_item.remove(position);//you can delete your item here
notifyDataSetChanged();
}
});
notifyDataSetChanged is to refresh view and updated the data.
Solution 4:
I was trying to remove it from Arraylist
, but actually I stored it in Hashmap
. I had to remove it from there: hashmap.remove(position);
solved my issue.
Post a Comment for "Remove Row From Listview Using Custom BaseAdapter"