Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawer_menu actions #20

Closed
pizzolante opened this issue Oct 28, 2015 · 3 comments
Closed

drawer_menu actions #20

pizzolante opened this issue Oct 28, 2015 · 3 comments

Comments

@pizzolante
Copy link

Hi, how i can add actions on click some elements into drawer menu?

Thanks

@pizzolante
Copy link
Author

this in BaseActivity have worked for me

protected void setupToolbar() {
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        toolbar.setNavigationIcon(R.drawable.ic_menu_white);

        navigationView.setNavigationItemSelectedListener(
            new NavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(MenuItem menuItem) {
                    int position = -1;
                    switch (menuItem.getItemId()) {
                        case R.id.menu_foo_1:
                            #
                        break;
                    }
                    drawerLayout.closeDrawer(Gravity.LEFT);



                    return false;
                }
            });


}
}

@tinasherobert
Copy link

*Note *, Replace this on BaseDrawerActivity

@Override
    protected void setupToolbar() {
        super.setupToolbar();
        if (getToolbar() != null) {
            getToolbar().setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    drawerLayout.openDrawer(Gravity.LEFT);
                }
            });
            vNavigation.setNavigationItemSelectedListener(
                    new NavigationView.OnNavigationItemSelectedListener() {
                        @Override
                        public boolean onNavigationItemSelected(MenuItem menuItem) {
                            int position = -1;
                            switch (menuItem.getItemId()) {
                                case R.id.news_feed:
                                    Snackbar.make(getCurrentFocus(), "Clicked!", Snackbar.LENGTH_SHORT).show();
                                    
                                    break;
                            }
                            drawerLayout.closeDrawer(Gravity.LEFT);
                            return false;
                        }
                    });
        }
    }

@gdaelexxer
Copy link

thank you let me do that

On Wed, May 11, 2016 at 1:43 PM, Tinashe notifications@github.com wrote:

*Note *, Replace this on BaseDrawerActivity

@OverRide
protected void setupToolbar() {
super.setupToolbar();
if (getToolbar() != null) {
getToolbar().setNavigationOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
drawerLayout.openDrawer(Gravity.LEFT);
}
});
vNavigation.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@OverRide
public boolean onNavigationItemSelected(MenuItem menuItem) {
int position = -1;
switch (menuItem.getItemId()) {
case R.id.news_feed:
Snackbar.make(getCurrentFocus(), "Clicked!", Snackbar.LENGTH_SHORT).show();

                                break;
                        }
                        drawerLayout.closeDrawer(Gravity.LEFT);

                        return false;
                    }
                });

    }
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#20 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants