簡體   English   中英

如何將數據/參數傳遞給 Android 中的另一個活動

[英]How do you pass data/parameters to another activity in Android

如何在 android 中將數據/參數值從一個活動傳遞到另一個活動?

我用過

loginname=txtloginname.getText().toString();
password=txtpassword.getText().toString();
Bundle bundle = new Bundle();
bundle.putString("loginname", loginname);
bundle.putString("password", password);
Intent newIntent=new Intent();
newIntent.putExtras(bundle);
setResult(RESULT_OK,newIntent);
finish();

但是我只能獲取登錄名值如何將登錄名和密碼鍵和值放在一起?

你可以說newIntent.putExtra("name",value); 多次使用它來添加多個數據。 並根據您存儲的數據調用getStringExtra("name"); 在接下來的活動中。

您可以使用以下方法:

getStringExtra()

暫無
暫無

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

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