Reputation: 18130
I want the Android Keyboard to pop-up on the startup of my activity. A simple google search shows that you just have to requestFocus
which I do in my .xml
, but it still doesn't pop up. Am I making any minor mistake that is causing this not to work?
Testing on:
Physical 4.1 Emulator 2.2
layout.xml:
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:ems="10"
android:hint="To:"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
Upvotes: 0
Views: 278
Reputation: 2045
This works:
myEditText.setOnFocusChangeListener( new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
});
Upvotes: 2
Reputation: 1338
Try this code:
EditText input = (EditText) findViewById(R.id.editText1);
InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
Upvotes: 0