S
S
Sergey Kamyshev2017-06-12 23:08:06
Java
Sergey Kamyshev, 2017-06-12 23:08:06

How to hide keyboard when opening navigationDrawer?

The main class is the NavigationDrawer template. I read the article https://habrahabr.ru/post/250765/ , but some library is used there and I have to completely rewrite the class because of this. Is there a way to hide the keyboard when navigationDrawer is opened other than including the com.mikepenz.materialdrawer library?

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();
}

Can't override onDrawerOpened method =(
@Override
    public void onDrawerOpened(View drawerView) {        
        InputMethodManager inputMethodManager = (InputMethodManager) MainActivity.this.getSystemService(Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(MainActivity.this.getCurrentFocus().getWindowToken(), 0);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Kamyshev, 2017-06-16
@ser_cool_geek

https://stackoverflow.com/questions/17515839/navig...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question