开发者

EditText - next button from keyboard - implementation

I have an EditText , after I write something and I click next i want to do a call to server. for example if i have edittext a, how I spec开发者_运维知识库ify that the action has to happen just after I click next ? I suppose that a.setOnClickLisner is not ok

Thank you in advance , Raluca


try this....

EditText.setOnEditorActionListener(new OnEditorActionListener()
{

    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
    {

        if(actionId==EditorInfo.IME_ACTION_NEXT) 
        {
                //Write your code here
}

    return false;
    }
});


Try this...

editText = (EditText) findViewById(R.id.editText);

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

                                    // PLACE CODE FOR CALLING SERVER.

                    return false;
                }
                return false;
                    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜