I created a ArrayList with an Custom Adapter to show a delete-Button next to each item.
How can I delete one item in the List by clicking it’s corresponding delete-Button?
I read that I have to add the following Code in my getView() method:
btnDel.setTag(position);
Next I should convert the position into an int since setTag returns an Object. How do I manage this?
And then, I should create a onClickListener() Function in my getView() like this:
btnDel.setOnClick....{
arrayList.remove(index);
adapter.notifyDataSetChanged();}
How do I get the number of the current selected remove-Button or what should I put in the remove()?
I’m new to android, so please give code-examples or easy-to-understand hints 🙂
Thanks.
You need to create something similar to this (at least this is the way which I was going to create this functionallity) :
Something similar to this should work for you.
Hope it helps! : )