[英]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.