javaandroidnavigation-drawerandroid-softkeyboardmaterialdrawer

Using MikePenz drawer, where can i handle onDrawerOpen, close soft keyboard


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.


Solution

  • 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);
    }