在布局中使用布局?
通过按按钮更改布局内的内容的最佳方法是什么? 我想要 6 个按钮,每次推送都有不同的内容。
我无法使用选项卡布局,因为我已经使用过它了..
Which is the best way to change the content inside a layout by pressing buttons?
I want 6 buttons and different content for each push.
I cannot use tab layout because i already used it so..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议使用 API 演示中设置的 gridview。您可以将其作为新项目从 Android SDK 导入。
它的工作方式类似于“所有应用程序”列表。但是,您可以更改按钮/图标/文本的布局方式。
I would suggest using the gridview that is set up in API Demos. You can import it in as a new project from the Android SDK.
It works effectively like the list of 'All Apps'. However you can change the way it lays out the buttons/icons/text.
在我正在开发的应用程序中,我有一个消息类型列表作为按钮。单击按钮可将显示更改为用于撰写所选消息的布局。为此,我为要更改的区域设置了 FrameLayout。我将此视图称为“compose_content”。当我想要更改内容时,我运行以下代码:
这会将 FrameLayout 内容更改为指定布局中的内容。
In an app I'm working on, I have a list of message types as buttons. Clicking a button changes the display to a layout for composing the selected message. To do this, I have a FrameLayout for the area I want to change. I reference this view as 'compose_content'. When I want to change the content, I run the following code:
This will change the FrameLayout content to the content from the specified layout.
一种解决方案是将所有 6 个视图放入膨胀的 xml 中,并根据按下的按钮设置该特定视图的可见性,其余视图消失
One solution can be to have all the 6 views inside your inflated xml and depending on the button pressed set the visibility of that particular view visible and the rest gone