0
我已经创建了一个地图应用程序来显示地图上的地点附近。当用户单击地图上的引脚时,会弹出一个警报对话框,要求用户显示路线。我的问题当快速连续多次点击引脚时,消息框出现不止一次。我不希望该消息出现一次以上。可以有人帮助我吗?我的代码是:处理覆盖物品上的快速连续拍打
protected boolean onTap(int pos) {
final ProgressDialog myDialog = ProgressDialog.show(LocationBasedServicesV1.this, "", "Please Wait...");
OverlayItem item = items.get(pos);
Thread backgroundThread = new Thread(new Runnable(){
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder dialog = new AlertDialog.Builder( LocationBasedServicesV1.this);
dialog.setTitle(listDetailsVO.getName());
dialog.setMessage("Address: "+destination+"\nPhone: "+finalPhone+"\nEmail Id: "+finalEmail+"\nDistance: "+finalDistance+unit);
dialog.setPositiveButton("Show Route", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0, int arg1) {
try {
Intent i = new Intent(LocationBasedServicesV1.this, ShowRouteActivity.class);
i.putExtra("destination", destination);
i.putExtra("source", currentAddress);
startActivity(i);
} catch (Exception e) {
e.printStackTrace();
}
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
dialog.show();
}
});
myDialog.dismiss();
}
});
backgroundThread.start();
}
这个想法正在工作......非常感谢 – Nishant 2011-12-21 07:11:03