3

I have multiple Edittext in my activity i want to hide by defult keyboard when view shows and show keyboard only when edittext is clicked i am not getting how to do this thanks Advance:)

2
  • there are lots of answer, non of them working ? Commented May 11, 2013 at 9:08
  • Here is also a hack for you, only added a linearlayout into your xml file. gist.github.com/XinyueZ/cc0be271686491dcf6e6 Commented Aug 20, 2014 at 12:11

1 Answer 1

4

try this.

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();

    answer_et.postDelayed(new Runnable() {
    @Override
    public void run() {
        InputMethodManager imm = (InputMethodManager)getSystemService(
        Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(edit_text.getWindowToken(), 0);
        }
    }, 100);

}

sometime edittext get focus after manually hide soft-keyboard.

so, delay 100 mSeconds and then after hide it forcefully in onResume() method.

Sign up to request clarification or add additional context in comments.

1 Comment

Or just add a view in the top layout, as the first view, as such: <View android:layout_width="0dp" android:layout_height="0dp" android:focusable="true" android:focusableInTouchMode="true"/>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.