[英]How to get information from an edit text that is entered by the user and move it to another activity as a TextView
I need to get information thats entered by the user in a EditText and move it to another activity by placing it under everything with a TextView. 我需要获取用户在EditText中输入的信息,然后将其放置在具有TextView的所有内容下,以将其移至另一个活动。 I'm new to this, and I'm sure it's simple. 我是新手,我敢肯定这很简单。 Please help. 请帮忙。 Thanks. 谢谢。
You don't want to do what you say you want to do, not exactly. 您不想做您想做的事情,不完全是。 You want to pass the information from one Activity to another, not the actual view. 您想将信息从一个活动传递到另一个活动,而不是实际视图。
At the point where you're launching the new activity: 在您启动新活动时:
String info = editText.getText().toString();
Intent intent = new Intent(this, MyNewActivity.class);
intent.putExtra("info_key", info);
startActivity(intent);
Then, in your onCreate()
in the new Activity: 然后,在新的Activity中的onCreate()
中:
Intent intent = getIntent();
String info = intent.getStringExtra("info_key");
textView.setText(info);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.