Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slide In button effect of List View item for Android

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?

like image 616
eunique0216 Avatar asked Jul 01 '11 04:07

eunique0216


1 Answers

This is just a bit more complicated to achieve. This is what I would do talking from a higher level.

  1. 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.

  2. 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.

  3. 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.

like image 125
Jona Avatar answered Oct 20 '22 00:10

Jona