If i click on my EditText, the virtual keyboard simple not shows up. The cursor is shown, but no keyboard to type on.
I even tried it with manually open but just no works.
Here is my code:
public class CreateNote extends Activity {
EditText titleEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createnote);
titleEdit = (EditText) findViewById(R.id.titleEdit);
titleEdit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager) CreateNote.this
.getSystemService(Service.INPUT_METHOD_SERVICE);
imm.showSoftInput(titleEdit, 0);
}
});
}
}
Snippet of Layout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#989898" >
<EditText
android:id="@+id/titleEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edittextdrawale"
android:ems="10"
android:textColor="#fff"
android:textColorHint="#fff" >
<requestFocus />
</EditText>
</FrameLayout>
What could be the reason of playing hide and seek of my virtual keyboard ? I test on real device, not on emulator.
edittext. requestFocus(); -> in code. This will open soft keyboard on which edit-text has request focus as activity appears. This open the keyboard at Activity creation.
You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.
Try with this, it worked for me.
EditText etHorseName = (EditText) getView().findViewById(R.id.horseName);
etHorseName.clearFocus();
in onCreate()
or where you want.
Late answer but here is how to solve it without adding code, just remove this from your XML:
<requestFocus />
No idea why the keyboard does not show up when this is set... It does show up however if you first loose the focus and then click on the edit text. I had the problem on Android 2.3.6 but it worked on 4.1.2, so maybe it was an early bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With