有人可以告诉我为什么我无法使用onClick()
dialog.setPositiveButton()
的{{1}}方法访问地址,纬度和经度变量吗?
onTouchEvent
答案 0 :(得分:1)
因为onClick被声明为匿名内部类
final String maddress = address;
final double lat = latitude;
final double lon = longitude;
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
Intent intent = new Intent(context,Fill_Information.class);
intent.putExtra("address", maddress); //HERE
intent.putExtra("latitude", lat); //HERE
intent.putExtra("longitude", lon); //HERE
context.startActivity(intent);
}
});
putExtra的键必须是唯一的,否则你只能找到你放在里面的lastValue