2011-12-21 74 views
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(); 
    } 

回答

1

检查针的位置假设你有5针,然后用户点击3位引脚上相同的引脚再次用户点击,那么你得到了相同的位置进入和Ontap()方法,然后就什么也不做否则只是解雇最后打开(如果你需要)并创建新的对话框/使用现有的对话框并显示该位置

+0

这个想法正在工作......非常感谢 – Nishant 2011-12-21 07:11:03