Search code examples
javaandroidselectfocusplaintext

How to automatically focus on Plaintext after going to another activity


I have an empty activity with just the PlainText on it. I want it so that after the user taps on the button that directs him to the empty activity it automatically selects/focuses on the PlainText bringing out the built-in android keyboard ready to get user's input.

I tried

        android:focusedByDefault="true"

but that doesn't seem to do anything after going to the empty activity.


Solution

  • You can try to do

    editText.requestFocus(); 
    

    on your empty activity's onCreate() method

    Set Focus on EditText See here.

    Note: Normally the general problem is "hot to remove auto focus" from EditText so it focuses automatically, so maybe you changed some attributes from your xml, please share your empty activity xml with us.