android:从图库中删除视图
我在我的应用程序中使用图库视图。该应用程序的设计使我可以从该图库中拖放视图。
如何从图库中删除拖动的视图?
I'm using a Gallery view in my app. The app is designed so that I can drag and drop a view from that Gallery.
How can I remove the dragged view from the Gallery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将其从底层适配器中删除。如果您正确执行此操作,
图库
将自行刷新。否则,请在适配器上调用notifyDataSetChanged()
以触发Gallery
更新。You remove it from the underlying adapter. If you do this correctly, the
Gallery
will refresh itself. Otherwise, callnotifyDataSetChanged()
on the adapter to trigger aGallery
update.如果您覆盖 ImageAdapter,您可以通过添加删除项目或将项目添加到图像列表的方法来随意修改内容,或者在示例的情况下,动态完全交换列表。我在启动时显示应用程序横幅,然后更改图库以将应用程序所处的模式显示为滑块。每当您调用修改 ImageAdapter 中数据集的方法时,请调用 imageAdapter.notifyDataSetChanged(),如 CommonsWare 上面所述:
If you override ImageAdapter you can modify the contents at will by adding methods to delete or add items to your image list(s) or in the case of the example, completely swap lists on the fly. I am displaying a app banner at startup, and then changing the Gallery to display the mode the app is in as a slider. Whenever you call a method that modifies the dataset in the ImageAdapter, call imageAdapter.notifyDataSetChanged() as CommonsWare says above :