Soft keyboard doesn’t hide

My app has one activity with three fragments. There is listview in first (Frg1) and third(Frg3) fragments. Second fragment(Frg2) has one editText.
Soft keyboard auto shown when i start Frg2. It’s right.
I try Frg2.onPause this code

@Override
public void onPause() {
    super.onPause();

    editText.post(new Runnable() {
        @Override
        public void run() {
            editText.clearFocus();
            imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
        }
    });
}

When i start Frg1 or Frg2 after Frg3 soft keyboard hides but after render Frg1/Frg3 keyboard shows again.

Code sample(in Frg3):

@Override
public void onResume() {
    super.onResume();
    editText.requestFocus();
}

and

        editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            editText.post(new Runnable() {
                @Override
                public void run() {
                    imm.showSoftInput(editText, 0);
                }
            });
        }
    });

In Manifest.xml

<activity
        android:name=".ContentActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize" >

What could be the problem?


Source: android

Leave a Reply