tags:

views:

32

answers:

2

I need to know when the user touches/taps/clicks the edittext in my activity.

How can I do this without interrupting the events, so the keypad still displays properly?

(And I need to know about it before the OS displays the keypad...if possible)

A: 

You should be able to do this by attaching an OnClickListener to your EditText. If you're concerned about blocking the UI thread in your OnClickListener, you can spawn a new Thread and do your work in there - though, if you do that, there's no guarantee the work will be done before the keypad shows up.

iandisme
If I attached a new onFocusChangeListener, it interrupts the keypad, and it has to be pressed twice to show it. When I override, is there a way to call super or something? Maybe I'm reaching...
just_another_coder
...onClickListener doesn't do the trick btw :)
just_another_coder
OK. Try looking at this... http://stackoverflow.com/questions/2403632/android-show-soft-keyboard-automatically-when-focus-is-on-an-edittext
iandisme
Actually, that was the example I was following. I also tried getting the activity window and setSoftInputMode, but it always takes 2 taps to reveal the keypad.
just_another_coder
+1  A: 
txtEdit.setOnTouchListener(new View.OnTouchListener(){
    public boolean onTouch(View view, MotionEvent motionEvent) {                                                       
         // your code here....
         getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);                
         return false;
    }
});
Mathias Lin
Thanks, although I didn't need the line above 'return false;' as the keypad appeared automatically.
just_another_coder