To do this in code, in your Activity
:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
I usually use the following to set the focus: Add following attributs to your xml-layout
<AutoCompleteTextView
android:focusable="true"
android:focusableInTouchMode="true">
</AutoCompleteTextView>
and set focus programmatically like
((AutoCompleteTextView) findViewById(R.autocomplete_zone)).requestFocus();
f.e. in onResume
or onWindowChanged
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
((AutoCompleteTextView) findViewById(R.autocomplete_zone)).requestFocus();
}
}
Solved it! In manifest I added following to the activity:
android:windowSoftInputMode="stateAlwaysVisible"
None of the above worked for me... this is what I used
txtView.getParent().requestChildFocus(txtView,txtView);
You can try this in the code if you want to forcefully show the keyboard.
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
then you can to use this code to close the keyboard:
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(autocomplete_zone.getWindowToken(), 0);