Android的:如何从一个GridView中删除项目,具有remaing项目洗牌到位项目、Android、GridView、remaing

2023-09-06 15:33:26 作者:求尔别敷衍俄╰

背景: 我有36个按钮的网格,可以说,一个6行和放大器; 6列编号从1到36,通过GridView和自定义的适配器

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.

建议?

推荐答案

具体而言,你需要从底层接口的数据集中删除相应的对象,然后调用 adapter.notifyDataSetChanged()。这是不会为你提供一个动画,不过,如果这是对这个问题的部分。

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.