如何连接两个活动 [英] how to connect two activities

查看:203
本文介绍了如何连接两个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个屏幕,这两个IMGS,我想添加一个按钮的页面女巫的下降将推动到第二个页面,当我点击你知道我it.do怎么会写吗?我知道如何创建一个按钮,但我不知道如何将两个屏幕连接!谢谢

i have made one screen with these two imgs and i would like to add a button down of the page witch will drive to a second page when i click it.do you know how i will write it in?i know how to create a button but i dont know how to connect the two screens!thanks

推荐答案

这任务是与startActivity完成();方法使用意图。

This task is accomplished with the startActivity(); method using Intents.

Intent i = new Intent(FromActivity.this, ToActivity.class);
startActivity(i);

在这种情况下,意图使用您的当前活动作为第一个参数的背景下,并在第二个参数目的地活动。

In this case the Intent uses your current Activity as the Context in the first parameter, and the destination Activity in the second parameter.

请确保您在第二个活动添加到清单也(它驻留在标签)!

Make sure that you add your second Activity to the manifest also (it resides in the tag)!

<activity android:name=".ToActivity"
          android:label="@string/app_name">
</activity>

这篇关于如何连接两个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆