I'm porting an iPhone app into android app and one of the difficulties is recreating functionalities that are native to iPhone.
I found a native functionality of iPhone: When user execute slide touch on a listed item in list view, a delete button appears.
Is there a version for this in android? Can it be used and reused/customized?
This is just a bit more complicated to achieve. This is what I would do talking from a higher level.
Create a custom ViewGroup/Layout to hold a list item. Inside this layout you have your text lines images or what ever you have and also the delete button. You also here listen for gestures to hide or unhide the delete button.
In your list adapter you are going to need to keep track of which item is showing the delete button and which is not. Also, you are going to need to apply a click listener to each of the list item delete buttons. Every time you assign these states on the list item you should setTag(...) and store the list item position so that when it's clicked you can tell which item number must be deleted.
After deleting you must refresh the list in order for it to take effect. Depending on what type of adapter you are using that's going to determine how you refresh the adapter.
Hopefully this makes some sense. But I definitely think this is the easiest way since I've done this a couple times with similar functionality.
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