Wrong fragment in ViewPager receives onContextItemSelected call

So this is some sort of idiotic design decision by Google or something that has just gone totally unconsidered. The simplest way to work around this is to wrap the onContextItemSelected call with an if statement like this:

if (getUserVisibleHint()) {
    // Handle menu events and return true
} else
    return false; // Pass the event to the next fragment

The compatibility library in ActionBarSherlock 3.5 had a hack like this.

Leave a Comment