2

i am using mikepenz drawer, i want my softkeyboard to be closed when ik open my drawer, didnt have a problem with doing this with the on hamburger item press, but can find where to handle closing the keyboard on opening the drawer by sliding.

mikepenz
  • 12,708
  • 14
  • 77
  • 117
D.Blazer
  • 192
  • 1
  • 2
  • 12
  • 1
    Did you implement the `OnDrawerListener` [here](https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L1056) as part of the `DrawerBuilder` class with method `withOnDrawerListener`? – t0mm13b May 10 '16 at 10:03
  • @t0mm13b, .... how can i have read over this. thanks a lot dude – D.Blazer May 10 '16 at 10:18

1 Answers1

4

after the information t0mm13b pointed me to, this is how i did it.

    result = new DrawerBuilder()
            .withActivity(this)
            .withTranslucentStatusBar(false)
            .withActionBarDrawerToggle(false)
            .addDrawerItems(drawerItemsArray)
            .withSavedInstance(savedInstanceState)
            .withOnDrawerListener(new Drawer.OnDrawerListener() {
                @Override
                public void onDrawerOpened(View view) {
                }

                @Override
                public void onDrawerClosed(View view) {
                }

                @Override
                public void onDrawerSlide(View view, float v) {
                    removeSoftKeyboard();
                }
            })
            .build();

remove soft keyboard method

public void removeSoftKeyboard() {
    InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
}
D.Blazer
  • 192
  • 1
  • 2
  • 12