【发布时间】:2015-12-01 22:06:49
【问题描述】:
我的第一个活动调试更正了位置名称和地址的输出,但是第二个活动给了我一个空值。有人可以帮忙吗?
FirstActivity
mySavedListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent next = new Intent(MyDestination.this, MyLocationDetail.class);
Bundle extra = getIntent().getExtras();
String locationName = myList.get(position).getLocation_name();
String address = myList.get(position).getAddress();
extra.putString("extra_location", locationName);
extra.putString("extra_address", address);
Log.d(TAG, "name is " + locationName);
Log.d(TAG, "address is "+ address);
intent.putExtras(extra);
startActivity(next);
}
});
第二活动
Bundle b = getIntent().getExtras();
String locationName = b.getString("extra_location");
String address = b.getString("extra_address");
Log.d(TAG, "location "+locationName);
【问题讨论】:
-
next.putExtras(extra);而不是intent.putExtras(extra);变量意图来自哪里? -
哦,对了,让我试试。谢谢
标签: android android-listview onitemclicklistener