开发者

make enter button clickable?

I have an EditText box and when you click it the soft keyboard comes up as usu开发者_运维知识库al, but how do make it so that when the enter button gets pressed it performs a action like your pushing enter, search, or go?

thank you.


This will work for you.

editTextBox.setOnKeyListener(new OnKeyListener()
    {
        public boolean onKey(View v, int keyCode, KeyEvent event)
        {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && (keyCode == KeyEvent.KEYCODE_ENTER))
            {

                //Code here
                return true;
            }
            return false;
        }
    });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜