从调用另一个活动 [英] Calling one Activity from another

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

问题描述

我如何可以调用从一个(当前)活动的另一个活动?我想打电话给其中包含从我的当前活动对话框消息框的活动。

How can I call another activity from one (the current) activity? I want to call an activity which contains a dialog message box from my current activity.

推荐答案

简单地说你的消息包,并把它传递给意图。下一步活动的onCreate函数提取包和表演。

Simply put your message in bundle and pass it to intent. On Next Activity's onCreate function extract the bundle and show.

Bundle b = new Bundle();
b.putString("message","your message");
Intent i = new Intent(this,NextActivity.class);
i.putExtras(b);
startActivity(i);

在接下来的活动的onCreate:

In next Activity's onCreate:

String message = (String) getIntent().getSerializableExtra("message");

显示消息现在....

show the message now....

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

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