调用其他活动活动? [英] Call other activities in an activity?

查看:156
本文介绍了调用其他活动活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有2个活动(ActivityOne和ActivityTwo)。我怎么会叫ActivityTwo从ActivityOne?那么,我怎么会回到ActivityOne从ActivityTwo?例如,我有所有的主机手机上的联系人列表视图。当我点击一个联系人,另一个活动显示信息,并允许该联系人的编辑。然后,我可以打后退按钮,我会回去的确切状态ActivityOne在之前我叫ActivityTwo。我在想一个Intent对象,但我不知道。可能有人张贴一些code?

Say I have 2 activities (ActivityOne and ActivityTwo). How would I call ActivityTwo from ActivityOne? Then how would I return to ActivityOne from ActivityTwo? For example, I have a listview with all the contacts on the host phone. When I tap on a contact, another activity shows information and allows editing of that contact. Then I could hit the back button, and I would go back to the exact state that ActivityOne was in before I called ActivityTwo. I was thinking an Intent object, but I am not sure. Could someone post some code?

推荐答案

在你的第一个活动(AcitvityOne),你可以调用

In your first activity (AcitvityOne) you could call

Intent intent = new Intent(this, ActivityTwo.class);
startActivityForResult(intent, CODE);

然后你可以重写

Then you can override

public void onActivityResult(int reqCode, int resultCode, Intent data) {

要获得这个活动的结果。

to receive the result of this activity

这篇关于调用其他活动活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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