I have an activity in which there are several buttons and a spinner 
containing a list of preset values. Unfortunately, if the user accidentally 
or mistakenly taps the spinner, the soft keyboard appears. Why? There is 
nowhere on the screen that expects typed input from the user.


More to the point, how can I prevent this from happening? After some 
research, I tried adding the following code:


 m_TricksPicker.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        InputMethodManager imm=(InputMethodManager)getApplicationContext().
            getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);

        
imm.hideSoftInputFromWindow(getParent().getCurrentFocus().getWindowToken(), 0);

        return false;
    }}) ;

Unfortunately, this throws a null pointer exception. Any other suggestions 
how to stop the keyboard from appearing (and I'd really like to understand 
why the system thinks it's necessary in the first place, when no user input 
is required)?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e229b1bb-03bc-4ffd-8f2b-09bb86e8610a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to