title: Android GUI :: Continuous click events hangs
body: <p>Hello 
  I have one ImageButton with single image. I have added onclick event and normally it works fine.When Imagebutton is clicked my add entry function works. </p>
  
  <p>Now when user continously clicks my imagebutton, My add entry functions executes that many times with same data. I want to prevent it. Such that, Imagebutton should not queue up to process next click event until my function gets executed completely.</p>
  
  <p>I tried to <code>myImageButton.setEnable(false)</code> as soon as OnClick event executes. And Doing </p>
  
  <p><code>myImageButton.setEnable(true)</code> after my data entry function.</p>
  
  <p>I also tried to put this code in <code>myImageButton.isEnabled()</code> but didnt work.</p>
  
  <p>How to ignore such queued click events? Is there any other way (than <code>setEnable()</code>) to ignore/eat click processing?</p>
  
  <p>I have checked by putting println statements that each click event is in sync...means all code executes in order.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>   private OnClickListener m_AddClickHandler = new OnClickListener()
      {
          public void onClick(View v)
          {
              if(m_bDoAdd)
              {
                  m_bDoAdd = false;
                  new AddTask().execute();
              }
              else
                  logData("Add::OnClick::not clicked");
          }
      };
  private class AddTask extends AsyncTask&lt;Void, Void, Integer&gt; 
      {
          @Override
          protected Integer doInBackground(Void... params) 
          {
              logData("doinbg, start"+m_bDoAdd);
              int iStatus =Add(m_data);
              logData("doinbg, start end, status="+iStatus+"flag="+m_bDoAdd);
              return iStatus;
          }
  
          @Override
          protected void onPostExecute(Integer result) 
          {
              logData("onpostExec, start"+m_bDoAdd);
              int iStatus = result;
              if (iStatus == 0)
              {
                  Toast.makeText(getApplicationContext(), R.string.strAdded, Toast.LENGTH_SHORT).show();
              }
              else if (iStatus == 1)
              {
                  Toast.makeText(getApplicationContext(), R.string.strAlreadyExists, Toast.LENGTH_SHORT).show();
              }
              else
              {
                  Toast.makeText(getApplicationContext(), R.string.strAddFailed, Toast.LENGTH_SHORT).show();
              }
  
              m_bDoAdd = true;
              logData("onpostExec, end"+m_bDoAdd);
          }
      }
  
      void Add()
      {
         // Add info to db (takes few msecs)
      }
  </code></pre>
  
  <p>I am still not getting "Add::OnClick::not clicked" in log.</p>
  
  <p>Any further clue?</p>