Domanda

Can we launch navigation drawer without using ActionBarDrawerToggle? In my implementation, I do not want to use action bar.

So, I don't want ActionBarDrawerToggle to open and close the drawer. I want to open the navigation drawer when hardware menu button is clicked.

I am targeting Android 2.2 and using support library v4.

As per my understanding, ActionBarDrawerToggle class will have implementation internally to handle the opening and closing of navigation drawer. Am I correct?

È stato utile?

Soluzione 2

I want to open the navigation drawer when hardware menu button is clicked

Not every Android device has a MENU button, so you better have some other solution beyond just that.

Also, using MENU to open a navigation drawer, instead of a menu -- may be viewed as odd behavior by some of your users.

I am targeting Android 2.2 and using support library v4.

If you are using DrawerLayout, it has openDrawer() and closeDrawer() methods that you can use that will open the drawer and close the drawer, respectively.

Altri suggerimenti

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ImageView ivNavigationIcon = //some image or button or menu what ever you want
ivNavigationIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.openDrawer(Gravity.LEFT);
}
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top