EditText onClick not shows Virtual Keyboard

Adam Varhegyi picture Adam Varhegyi · Feb 11, 2013 · Viewed 8.1k times · Source

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.

Answer

Sergio Andreotti picture Sergio Andreotti · Feb 11, 2013

Try with this, it worked for me.

EditText etHorseName = (EditText) getView().findViewById(R.id.horseName);
etHorseName.clearFocus();

in onCreate() or where you want.