action for the cap item "Navigation Drawer Activity"

Asked

Viewed 13 times

0

Good afternoon,

I created a project with the tamplete "Navigation Drawer Activity" and I would like to know how by action to the menu of the 3 dots -> Sttings of the top, I tried as follows:

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);

    menu.getItem(0).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(getBaseContext(), "ola", Toast.LENGTH_SHORT);
        }
    });
    return true;
}

inserir a descrição da imagem aqui

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.