2011-06-14 62 views
1

如何在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(); 

但我只能得到登錄名值如何把兩者登錄名和密碼鍵和值?

+0

你能後你是如何它接收到另一個活動代碼 – Stuti 2011-06-14 07:35:23

+0

喜Stuti,我得到這樣的:演員= getIntent()getExtras()。如果(extras == null){ newString = null; if(extras == null) } else { newString = extras.getString(「STRING_I_NEED」); } – sudo 2011-06-14 08:58:45

回答

10

你可以說newIntent.putExtra("name",value);多次使用它來添加多個數據。取決於您存儲的數據,請在下一個活動中撥打getStringExtra("name");

+0

嗨devA,它是getExtra()?我沒有找到getExtraString()。 – sudo 2011-06-14 09:00:28

+0

雅做同樣的事情,並施放它.. – ngesh 2011-06-14 09:01:12

1

您可以使用方法:

getStringExtra() 
相關問題