I have a custom listview item that includes a 'remove' button. I created a custom adapter called LazyListAdapter
that extends BaseAdapter
. Inside the getView method that I override I set this button's onclick method as follows:
@Override
public View getView(final int pos, View convertView, ViewGroup parent) {
View v = convertView;
// Some other things...
ImageButton removeFav = (ImageButton) v.findViewById(R.id.removeFavorites);
removeFav.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// I delete the object from Parse database here,
// Therefore I want the view to disappear here
}
}
How can I delete or somehow hide the corresponding view by using a code inside this onclick method? Or should I change my approach?
Thank you so much in advance.
Try this
@Override
public View getView(final int pos, View convertView, ViewGroup parent) {
View v = convertView;
// Some other things...
ImageButton removeFav = (ImageButton) v.findViewById(R.id.removeFavorites);
removeFav.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// After you delete the object from Parse database here,
notifyDataSetChanged();
}
}
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