简体   繁体   English

如何在应用程序启动时添加弹出选项屏幕? 安卓工作室

[英]How to add pop up option screen at start of app? Android studio

I'm looking to have a window pop up at the very start of my android app with two options on it.我希望在我的 android 应用程序一开始就弹出一个窗口,上面有两个选项。

I have two functional buttons already in my app and I'd like the user to pick one of the two buttons before they get in to the app.我的应用程序中已经有两个功能按钮,我希望用户在进入应用程序之前选择两个按钮之一。

Lets say the screen pops up at launch and I'd like it to say "Please choose either 'button1' or 'button2'"假设屏幕在启动时弹出,我希望它说“请选择‘button1’或‘button2’”

I've found a few solutions but none that I can actually get working...think that might be might novice status though.我找到了一些解决方案,但没有一个我可以真正开始工作……但我认为这可能是新手状态。

Thanks for any help.谢谢你的帮助。

You should create a splash screen (many tutorials can be found on this, here is an example).您应该创建一个启动画面(可以在此找到许多教程, 这里是一个示例)。 After having this activity, you can create a Dialog with 2 buttons (example here ).完成此活动后,您可以创建一个带有 2 个按钮的Dialog此处的示例)。

You can set a positive and negative button on the dialog to do this, and also use a callback for the click behavior (example here ).您可以在对话框上设置正面和负面按钮来执行此操作,还可以对单击行为使用回调(示例此处)。

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

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