[英]How to pass two parameters in android?
您好,我想將片段中的兩個變量(ref和log)傳遞給我的活動,但該日志未顯示在edittext中。 您能幫我改正我的密碼嗎? 似乎在第二個活動中日志為空,因為tid2為空,但是我不明白原因?
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity().getApplicationContext(), ViewProduitC.class);
HashMap<String, String> map = (HashMap) parent.getItemAtPosition(position);
String tid = map.get("ref");
intent.putExtra("ref", tid);
String tid2 = map.get("log");
intent.putExtra("log", tid2);
startActivity(intent);
}
活動日志為空。 為什么?
et_login = (TextView) findViewById(R.id.et_login);;
Intent intent = getIntent();
log = intent.getStringExtra("log");
String ref2 = intent.getStringExtra("ref");
et_login.setText(log);
首先檢查tid,tid2是非空字符串,如果它們包含值,則在片段中嘗試在Log中打印它們
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.