0

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.

2 Answers2

1

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.

Emre Akcan
  • 982
  • 10
  • 27
  • Thanks dude, this solved my issue + the keyboard shows: if(editText.requestFocus()) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } – Rudolph Reyes Jun 27 '20 at 12:37
-1

You can try to do

editText.setFocusableInTouchMstrong textode(true);
editText.setFocusable(true);
editText.requestFocus();

on your empty activity's onCreate() method

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197