title: In EditText, popup a dialog when clicking on specific subset of text
body: <p><strong>Found two solutions - please see selected answer</strong></p>
  
  <p>When the user clicks in a certain region of an EditText, I want to popup a dialog.  I used onClick to capture the click.  This partially works: the first time the user taps the EditText, the soft keyboard pops up and the dialog doesn't.  Subsequent taps bring up the keyboard and then the dialog (and the keyboard disappears).</p>
  
  <p>I suspect this has something to do with the EditText gaining focus.</p>
  
  <p>Here's a code snip:</p>
  
  <pre><code>public class PrefixEditText extends EditText implements TextWatcher, OnClickListener
  {
    public PrefixEditText (Context context)
    {
      super (context);
      setOnClickListener (this);
    }
  
    @Override
    public void onClick(View v)
    {
      int selStart = getSelectionStart();
      if (selStart &lt; some_particular_pos)
        bring_up_dialog();
    }
  }
  </code></pre>
  
  <p>IMPORTANT: I don't want to completely disable the normal EditText behavior.  I want the user to be able to make region selections (for copy &amp; paste).  I probably still want it to gain focus (so I don't break the model when people with physical keyboards use the app).  And it's ok for the click to set the cursor position.  Thus, solutions that override onTouch and block all onTouch actions from the EditText will not work for me.</p>
  
  <p><strong>UPDATE</strong>  I've discovered a bit more.  If the EditText is gaining focus, onFocusChange gets called and onClick does not.  If it already has focus, onClick gets called and onFocusChange does not.</p>
  
  <p>Secondly, it's possible to hide the keyboard by calling </p>
  
  <pre><code>setInputType (InputType.TYPE_NULL);
  </code></pre>
  
  <p>Doing so in onFocusChange works - the keyboard never shows up.  Doing so in onClick (assuming the keyboard was hidden before the click) apparently is too late - the keyboard shows up and then disappears.</p>
  
  <p>The next idea to try would be to hide the keyboard during onTouch.  However, I'm afraid to mess with that code - seems that whatever I figure out would be very fragile with respect to future versions of EditText.</p>
  
  <p>Any thoughs on this?</p>