Dmitriy
Dmitriy

Reputation: 93

Android option menu

In my project i have activity with options menu. I override onOptionsItemSelected method and add my handlers to menu items (switch-case block). But in one handler i need access to another menu item, how i can do that? findViewById doesn't work

 @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.visit:
                    //how to access another MenuItem from here?
                    return true;
                }
...

Upvotes: 0

Views: 955

Answers (1)

Valentin Rocher
Valentin Rocher

Reputation: 11669

When creating your menu items, you could put the MenuItem you want to check in an attribute (i.e. one of the private fields of your class). This way, when you go into your method, you'll be able toacces the other menu item.

Upvotes: 2

Related Questions