簡體   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

我需要獲取用戶在EditText中輸入的信息,然后將其放置在具有TextView的所有內容下,以將其移至另一個活動。 我是新手,我敢肯定這很簡單。 請幫忙。 謝謝。

您不想做您想做的事情,不完全是。 您想將信息從一個活動傳遞到另一個活動,而不是實際視圖。

在您啟動新活動時:

String info = editText.getText().toString();
Intent intent = new Intent(this, MyNewActivity.class);
intent.putExtra("info_key", info);
startActivity(intent);

然后,在新的Activity中的onCreate()中:

Intent intent = getIntent();
String info = intent.getStringExtra("info_key");
textView.setText(info);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM