从一个活动移动到下一个Android的Android

2023-09-12 10:10:15 作者:少年亡了城、

我正在开发中的Andr​​oid应用程序有一个登录界面。现在我能够成功地接收来自服务器的响应。经过一个成功的响应应该带我到下一个活动或类,我展示一个新的屏幕/活动。我应该怎么做才能实现这一目标。

I am developing an application in android which has a login Screen. Right now I am able to receive the response from the server successfully. After a successful response it should take me to the next activity or class where I display a new screen/activity. what should I do in order to achieve this.

推荐答案

在Android中使用的是意图改变从一个活动到另一个。在这种情况下,你可以使用一个明确的意向。在code这将是这样的:

In Android you are using Intents to change from one Activity to another. In this case you would use an explicit Intent. In code this would like this:

Intent goToNextActivity = new Intent(getApplicationContext(), YourNewClass.class);
startActivity(goToNextActivity);

请务必YourNewClass添加到表现为另一个活动是这样的:

Be sure to add YourNewClass to the manifest as another activity like this:

<activity android:name=".your.package.YourNewClass" />

有一个仔细看看意图的文档。你也可以阅读有关的应用程序基础的文件的文档中它是有点深,只是回答这个问题但它会给你的Andr​​oid的最重要的概念的见解。

Have a closer look at the documentation of Intent. You can also read the document about application fundamentals in the documentation it is somewhat to deep to just answer this question but it will give you insights in the most important concepts of android.