简体   繁体   English

如何从用户输入的编辑文本中获取信息并将其作为TextView移至另一个活动

[英]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.

相关问题 Android Studio:如何从活动获取用户输入(从微调器和编辑文本)到另一个活动? - Android Studio: How do I get user input (From Spinner and Edit Text) from activity to another activity? 从另一个活动获取textView的文本 - Get text of textView from another activity 从编辑文本获取文本到另一个活动 - Get text from edit text to another activity 如何使用SharedPreferences保存在edittext中输入的文本,并将其显示在另一个Activity中的TextView中 - How to use SharedPreferences to save the text entered in edittext and display it in TextView in another Activity 如何通过从userinput(edittext)获取文本并将其放入另一个活动的textview中? - How to pass get text from userinput (edittext) and put into a textview in another activity? 如何在活动片段中编辑 textview - how to edit textview in fragment from activity 如何在另一个活动中将列表项名称从列表视图转换为文本视图? - How to get the list item name from a listview to a textview in another activity? 如何获取另一个活动中的TextView的值? - How to get value of a TextView which is in another activity? 如何从另一个活动刷新我的Textview - How to refresh my Textview from another activity 如何从另一个类更新 Activity 的 TextView - How to update a TextView of an Activity from another class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM