从到的EditText TextView的传递价值价值、EditText、TextView

2023-09-04 06:35:07 作者:- 我怕的是人心

我想借此从的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.