contextual action mode in fragment - close if not focused?

前端 未结 5 821
小蘑菇
小蘑菇 2021-02-04 15:08

i implemented a contextual action mode bar in a nested fragement. This fragment is part of a view pager and the view pager is also a fragment and part of a navigation drawer.

5条回答
  •  面向向阳花
    2021-02-04 16:01

    This worked for me:

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        if (!isVisibleToUser && this.listView != null) {
            //HACK this is done in order to finish the contextual action bar
            int choiceMode = this.listView.getChoiceMode();
            this.listView.setChoiceMode(choiceMode);
        }
    }
    

提交回复
热议问题