如何在Android中打开新屏幕?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2085443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:29:06  来源:igfitidea点击:

how to Open new screen in Android?

androidandroid-activityscreenandroid-intent

提问by UMAR

i am new to android and i have created a login page after verifing login

我是 android 新手,我在验证登录后创建了一个登录页面

i get results true or false on the bases of user authentication now my goal is to show another screen on successful authentication with some new textboxes and button i mean new layout how to achieve this???

我根据用户身份验证得到的结果是真还是假,现在我的目标是使用一些新的文本框和按钮显示另一个成功身份验证的屏幕我的意思是新布局如何实现这个???

any help would be appriciated.

任何帮助将被appriciated。

采纳答案by Marcin Gil

You want to start new activity. You can read more on initiating new Activities at Android documentation.

你想开始新的活动。您可以在Android 文档 中阅读有关启动新活动的更多信息

However you might consider making a "normal" application screen and call another Activity for login purposes instead of having a login page and redirection.

但是,您可能会考虑制作一个“普通”应用程序屏幕并调用另一个 Activity 进行登录,而不是使用登录页面和重定向。

So if page/Activity_A requires user to be logged in, you call LoginActivitywith startActivityForResultand get true/false if user has properly logged in.

因此,如果 page/Activity_A 需要用户登录,您可以使用startActivityForResult调用LoginActivity并在用户正确登录时获取 true/false。

回答by Arun

create an Intent and pass the intent to startactivty method. ake sure your activity should be defined in manifest file

创建一个 Intent 并将 Intent 传递给 startactivty 方法。确保您的活动应在清单文件中定义

回答by Sumit M Asok

Read about Intents

阅读意图

intents are used to start new activity

意图用于开始新的活动

Activity is the super class that represents each of your view corresponding to your layout

Activity 是超类,代表您的布局对应的每个视图

in Professional Android App Dev- WROX by Retro Meier gives good examples for this in a chapter for Intents and Broadcast.

在 Retro Meier 的 Professional Android App Dev-WROX 中,在 Intents 和 Broadcast 一章中给出了很好的例子。