Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialProbal Das
13,834 PointsCreate a list item delete functionality in android
Greetings All,
I am working on an app and I am trying to achieve the following: I have list of users displayed in a GridView. When I long click on any of the users a small close (x) icon should display on the top-right corner of all the users. Clicking the close icon on any user will remove the user from the list. And If I touch somewhere else or use the back button, then the close icon should disappear. I have seen this kind of functionality in some launchers which gives uninstallation option when you long click on them. They sometimes also have nice wobble effect on the icon. Not sure what this effect is called. Anyways till now what I have managed to do is to create an OnItemLongClickListener for the GridView. In the User Adapter class I have kept a flag which when true should show the close button. In the OnItemLongClickListener I set this above value to true, and the close icons are displayed. Now I am not sure on what condition I should make the close Icons disappear. Therefore I am stuck.
Thanks in advance for any kind of help.
Mazen Halawi
7,806 PointsMazen Halawi
7,806 Pointsin the adapter class that you are using to populate your list, specifically the getView() function, add setOnClickListener on the returned view and put your code there. it would be more helpful if we could see your code to determine what you are doing exactly. im not sure if the code you did will show the delete button on all the views or just the single item, im also confused if its a grid or a list. and for the wobble effect you mentioned earlier i think you should imply some animation.