Skip to content Skip to sidebar Skip to footer

Editview Perform An Action On Click

I have an EditView and I have added : android:imeActionLabel='Go' This is showing 'Go' button in keyboard, but I don't know how to perform an action when user clicks 'Go' button.

Solution 1:

EditText.OnEditorActionListener is what you are looking for, the API Documentation can be found here. The action that will be called for the GO button is EditorInfo.IME_ACTION_GO. I have provided a brief example below.

editText.setOnEditorActionListener(new OnEditorActionListener()
{
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
        {
            if(actionId==EditorInfo.IME_ACTION_GO)
            {
                    //Handle go button pressed
            }
            return false;
        }
});

Post a Comment for "Editview Perform An Action On Click"