如何通过TextView的价值? [英] How to pass the value of textview?

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

问题描述

任何一个可以告诉我如何通过TextView中的值(如果在TextView的5价值,我们只传递一个)从一个屏幕到下一个屏幕。考虑这样的情况:我有两个屏幕,第一个屏幕与一个TextView的第二活动有一个TextView的和按钮

Can any one tell me how to pass the value of textview (if there are five value in textview and we pass only one) from one screen to its next screen. Consider the case: I'm having two screens, first screen with one textview and the second activity have one textview and button.

如果我点击第一个值,那么它必须移动到第二个活动TextView的。

If I click the first value then it has to move to second activity textview.

推荐答案

为了通过屏幕之间的状态信息,你需要先定义你的意图,你会通过到 startActivity(),然后使用 putExtra()方法上的意图额外的信息添加到它。

In order to pass state information between screens, you need to first define your Intent which you will pass to startActivity(), then use the putExtra() method on the Intent to add extra information to it.

Intent i = new Intent();
i.setClassName("com.example", "com.example.newscreen");
i.putExtra("string1", "some string");
i.putExtra("string2", "some other string");
startActivity(i);

现在获得下一个屏幕上的值,你会做这样的事情:

Now to get the values on the next screen, you'd do something like this:

Intent i = getIntent();
Bundle b = i.getExtras();
String string1 = b.getString("string1");
String string2 = b.getString("string2");

这篇关于如何通过TextView的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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