![](/img/trans.png)
[英]Android Studio: How do I get user input (From Spinner and Edit Text) from activity to another activity?
[英]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.