android Intent 如何传递 hashmap
For example, when sending the intent:
HashMap<String, String> hashMap = new HashMap<String, String>(); hashMap.put("key", "value"); Intent intent = new Intent(this, MyOtherActivity.class); intent.putExtra("map", hashMap); startActivity(intent);
And then in the receiving Activity:
protected void onCreate(Bundle bundle) { super.onCreate(savedInstanceState); Intent intent = getIntent(); HashMap<String, String> hashMap = (HashMap<String, String>)intent.getSerializableExtra("map"); Log.v("HashMapTest", hashMap.get("key")); }
若文章对您有帮助,帮忙点个赞!
(微信扫码即可登录,无需注册)