如何设置另一个活动的TextView的? [英] How to set TextView of another Activity?

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

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android\">How我传递活动之间的数据,Android的?

我有两个活动。一个用文字和图片的意见和其他与一个按钮。

I have two activities. One with text and image views and the other with a button.

我想点击活动按钮,转到第二个活动,并设置该次活动的文字和图像。

I would like to click the button on the activity, go to the second activity and set the text and images of that second activity.

谁能给我任何帮助吗?

推荐答案

1 使用意图

2 为了保持它的简单,你可以使用 PutExtra()将数据发送到另一个活动与该
       意图,并能通过使用获得的另一项活动中的数据 getExtras()

2. For Keeping it simple you can use PutExtra() to send the data to another activity with the intent, and can get the data on the another activity by using getExtras()

3 您也可以使用 startActivityforResult()同样的目的

/////////////编辑//////////

例如:

在活动Class_One

Intent i = new Intent(Class_One.this , Class_Two.class);
i.putExtra("Name", name);
startActivity(i);

在活动Class_Two

Intent i = getIntent();
String name = i.getExtras().getString("Name");

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

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