开发者

make enter button clickable?

开发者 https://www.devze.com 2023-03-14 08:23 出处:网络
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

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

精彩评论

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