我試圖將字符串從一個活動傳遞到另一個活動。我似乎無法獲得額外的意圖。我哪裏錯了?從意圖額外獲取空值
下面是代碼
爲了把額外的進入意圖:
public void onClick(View v) {
// TODO Auto-generated method stub
String string = editTextFeild.getText().toString();
Intent i = new Intent("com.com.com.otherclass");
i.putExtra("dat", string);
startActivity(new Intent("com.com.com.otherclass"));
}
要從意圖獲取數據(在com.com.com.otherclass):
Bundle bundle = getIntent().getExtras();
if (bundle != null){
String string = bundle.getString("dat");
textView.setText(string);
}
ps這些都不是我的代碼:)
感謝提前:)
您是否檢查過editTextField不爲null? –
是的每當我測試它,它已經有了一個值:) – Nick
爲什麼你正在構建一個新的意圖,甚至沒有使用它......? – JoxTraex