gurehbgui
gurehbgui

Reputation: 14694

Android Navigation Drawer App not reacting on a click

I have a Problem, I made a Android Navigation Drawer App and added my stuff.

Now I have a Problem and I don't know where the bug could be:

When I want to see the Navigation Drawer, I only can use the swipe gesture from the left device border.

When I click at the top left corner enter image description here to show the menu it does not work.

Any tips for a solution?

Upvotes: 0

Views: 105

Answers (2)

Hank G
Hank G

Reputation: 487

You need to set a click listener for the button and then you will have the ability to open and close the drawer: this can be done in the Activity after onCreate() is called.

viewButton = (ImageButton)findViewById(R.id.actionBarViewButton);
    viewButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v){
            if(mDrawerLayout.isDrawerOpen(Gravity.RIGHT)){
                mDrawerLayout.closeDrawer(Gravity.LEFT);
            }

            else{
                mDrawerLayout.openDrawer(Gravity.RIGHT);
            }
        }
    }); 

Upvotes: 1

Larry Schiefer
Larry Schiefer

Reputation: 15775

The easiest way is to use ActionBarDrawerToggle, tying it to your Activity and DrawerLayout. Note that you'll also need to call ActionBar.setHomeButtonEnabled(true) in order for your onOptionsItemSelected() callback to see the android.R.id.home as being selected.

Upvotes: 1

Related Questions