如何在 XML 中填充 gridview

发布于 2024-10-11 14:15:54 字数 87 浏览 9 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

刘备忘录 2024-10-18 14:15:54

您无法将子级添加到 XML 中的 GridView。您需要创建一个适当的Adapter并通过setAdapter()将其与GridView关联起来。

最有可能的是,如果您只有四个按钮,那么您一开始就不需要 GridView

You cannot add children to a GridView in XML. You need to create an appropriate Adapter and associate it with the GridView via setAdapter().

Most likely, if you only have four buttons, you do not want a GridView in the first place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文