How to handle onContextItemSelected in a multi fragment activity?

前端 未结 11 2128
天命终不由人
天命终不由人 2020-11-29 17:26

I\'m currently trying to adapt my application to use the \"Compatibility Libraries for Android v4\" to provide the benefits of the usage of fragments even to Android 1.6 use

11条回答
  •  难免孤独
    2020-11-29 17:57

    Another one solution:

    @Override
    public boolean onContextItemSelected(MenuItem item) {
        if (getUserVisibleHint()) {
            // context menu logic
            return true;
        }
        return false;
    }
    

    Based upon this patch from Jake Wharton.

提交回复
热议问题