Search code examples
androidandroid-layoutandroid-edittextandroid-button

How to go to Edittext when button clicked in android


I have a layout which contains button at top and some textviews and then at bottom I have edittext.When I click button, it should point to edittext. How to proceed? Thanks in advance.


Solution

  • To show keyboard when EditText is in focus mode.

     myEditText.requestFocus();
              if(myEditText.requestFocus()) {
                    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                }
    

    If you want to show some message

    myEditText.setError("Please Enter Valid Value!");
    

    You can remove message focus by Using:

    myEditText.clearFocus();