如何在 XML 中填充 gridview
我有一个 gridview,只需要按住 4 个按钮,但是在执行时我不断收到 AdapterView 不支持的操作错误。甚至可以通过xml填充gridview吗?
I have a gridview that just needs to hold 4 buttons, how ever I keep getting an operation not supported in AdapterView error when executing. Can you even fill a gridview through xml?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法将子级添加到 XML 中的
GridView
。您需要创建一个适当的Adapter
并通过setAdapter()
将其与GridView
关联起来。最有可能的是,如果您只有四个按钮,那么您一开始就不需要
GridView
。You cannot add children to a
GridView
in XML. You need to create an appropriateAdapter
and associate it with theGridView
viasetAdapter()
.Most likely, if you only have four buttons, you do not want a
GridView
in the first place.