开发者

How to catch soft-keyboard input

I need an help:how can i catch in开发者_开发知识库put from soft-keyboard? Now I catch it with an edit text, but i don't like this solution. There are other methods? Thanks for any answers. Bye


As it is this question is incredibly vague. Any more specifics you could add about what you are trying to accomplish would likely lead to a better answer.

I would think you can override onKeyDown or dispatchKeyEvent in your Activity and you'll get callbacks when a key on the keyboard is pressed. It will send you the action and keycode in a KeyEvent object.


textView1.setOnKeyListener(new OnKeyListener() { 


            @Override 
            public boolean onKey(View v, int keyCode, KeyEvent event) { 
                // TODO Auto-generated method stub 

                { 
                    if(keyCode == ?) //check it
                    { 
                        //do some stuff
                    } 
                } 
                return false; 
            } 
        }); 


This method just fires when you're using the hardware keyboard, with the soft keyboard it didn't fire. Some suggestion are to use a TextWatcher.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜