2011-12-21 37 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