Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How do I remove an item from a gridview, having the remaing items shuffle into place

BACKGROUND:
I have a grid of 36 buttons, lets say a 6 rows & 6 columns numbered 1 to 36, displayed 2 rows at a time via a GridView and custom Adapter

The grid displays fine, and all of the scrolling works properly.

QUESTION:
I want to be able to click on an item, have it removed from the grid and the remain items shuffle up into place. Currently I am able to disable the item disabled, set its visibility to INVISIBLE or GONE, but none of these will actually remove it from the display.

Suggestions?

like image 949
Noah Avatar asked Oct 25 '22 17:10

Noah


1 Answers

Specifically, you need to remove the corresponding object from the data set of the underlying adapter and then call adapter.notifyDataSetChanged(). This isn't going to provide you with an animation, though, if that was part of this question.

It may be interesting to try a tween animation for the item in question and then finally remove it from your adapter at the end. I'm not well-versed in animation, so I'm not sure how well this will work in an AdapterView.

like image 168
Matthew Willis Avatar answered Oct 27 '22 10:10

Matthew Willis