从到的EditText TextView的传递价值 [英] Passing value from a EditText to TextView

查看:92
本文介绍了从到的EditText TextView的传递价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想借此从的EditText值从一个页面,并显示该值在另一页一个TextView。我该怎么办呢?我怎么能存储的EditText值? Plesae帮我.... 感谢你..

I want to take the value from a EditText from one page and to display that value to a TextView in another page. How can I do that? How can I store values in EditText? Plesae Help me.... Thanking you..

推荐答案

当你提到不同的页面上的你在一个新的活动的意思吧?

When you mention "on a different page" you mean in a new activity right?

假设多数民众赞成你的意思是,你必须多投的EditText的内容转换成一个包,并把它交给下一个活动。这里有让你开始一个样本。

Assuming thats what you mean, you must simply cast the content of the EditText into a bundle and sent it to the next activity. Here is a sample to get you started.

该C $ CS $应该是在方法使用的是开始新的活动。

This codes should be in the method you are using to start the new activity.

有关的第一个活动:

EditText txtTitle = (EditText)findViewById(R.id.txtTitle);
Intent i = new Intent(this, com.dzinesunlimited.quotetogo.Step2.class);
Bundle bundle = new Bundle();
bundle.putString("title", txtTitle.getText().toString());
i.putExtras(bundle);
startActivity(i);

对于第二个活动

For the second activity

这code,在我的情况是在OnCreate()方法。

This code, in my case is in the onCreate() method.

Bundle bundle = this.getIntent().getExtras();
String title = bundle.getString("title");

((TextView)findViewById(R.id.summaryTitle)).setText(title);

希望这有助于。

Hope this helps.

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

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