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