How to handle drag-to-select of sub-menu items on Kitkat?

好久不见. 提交于 2019-12-06 08:20:14

Is this a bug?

I can recreate it too. I checked the AOSP's issue tracker and didn't find anything, but it certinaly appears to be a bug.

Why does this occur?

I think it's related to the ListPopupWindow.ForwardingListener, but I'm not certain exactly where the problem occurs right now.

How can I fix it?

Call Activity.invalidateOptionsMenu after you select a MenuItem.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menuItem_sortByInstallTime:
            // Do something
            break;
        case R.id.menuItem_sortByUpdateTime:
            // Do something
            break;
        case R.id.menuItem_sortByAppName:
            // Do something
            break;
        case R.id.menuItem_sortByPackageName:
            // Do something
            break;
        default:
            break;
    }
    invalidateOptionsMenu();
    return true;
}

Limitations

Unfortunately, it looks like this solution is only viable for menu items not placed in the action bar's overflow menu. If you'd like to follow further updates regarding this problem, you should refer to issue #69205 on the AOSP's issue tracker.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!