简体   繁体   English

Android弹出列表对话框

[英]Android pop up list dialog

I want to add an dialog to my application. 我想在我的应用程序中添加一个对话框。 I want it to launch as soon as the first activity loads. 我希望它在第一个活动加载后立即启动。 But instead of having just a single message to display and having a 'yes' and 'no' button like this 但不是只显示一条消息,而是像这样显示“是”和“否”按钮 在此输入图像描述

I want it to display a list of message like this 我希望它显示这样的消息列表 在此输入图像描述 If there is a tutorial that speaks on this subject I would be happy to look at it and also I would anybody by any chance know how to align these list with bulletins. 如果有一个关于这个主题的教程,我很乐意看到它,我也会有任何机会知道如何将这些列表与公告对齐。

1 Create a custom dialog layout (XML file). 1创建自定义对话框布局(XML文件)。 2 Attach the layout to Dialog. 2将布局附加到Dialog。 3 Display the Dialog. 3显示对话框。 4 Done. 4完成。 Tutorial here 这里的教程

If there is a tutorial that speaks on this subject I would be happy to look at it 如果有一个关于这个主题的教程,我很乐意看一下

Your best bet would be to start Here in the Docs . 你最好的选择是从Docs开始。 They show a great example of doing it with a Dialog . 他们展示了使用Dialog做到这一点的一个很好的例子。

Another option, if this can be the entire Activity since you want it to happen when if first starts, is to use a ListView for your Activity and use setChoiceMode() on it. 另一个选项,如果这可能是整个Activity因为你希望它在第一次启动时发生,就是为你的Activity使用ListView并在其上使用setChoiceMode() You can find more about that in the Docs 您可以在文档中找到更多相关信息

With this second option, you can make the Activity appear as a Dialog by adding this line to your <activity> tag in the manifest.xml 使用第二个选项,您可以通过将此行添加到manifest.xml <activity>标记来使Activity显示为Dialog

android:theme="@android:style/Theme.Dialog"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM