今天在修改一个问题的时候,用到了ActivityChooserView类,但是,这个类会自动显示两个按钮,一个是点击有下拉框的,一个是选择应用以后,显示应用图标的。因为应用图标跟当时的环境非常的不搭,所以想办法去掉这个图标。其实很简单,只需要用一个方法就行了,如下所示

  MenuItem sendItem = menu.findItem(R.id.action_send);
        MenuItem shareItem = menu.findItem(R.id.action_share);
        if (mAppBridge != null) {
            if (shareItem != null) {
                shareItem.setVisible(canShareByHotKnot);
                ((ActivityChooserView) shareItem.getActionView())
                    .setRecentButtonEnabled(false);

            }    
            if (sendItem != null) {
                sendItem.setVisible(false);
            }    
        } else {
            if (shareItem != null) {
                shareItem.setVisible(false);
            }    
        }    

 

这个方法

((ActivityChooserView) shareItem.getActionView())
                    .setRecentButtonEnabled(false);

就是控制应用显示按钮的

相关文章:

  • 2021-06-18
  • 2021-11-20
  • 2021-10-17
  • 2021-11-08
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-09
  • 2021-12-19
  • 2022-02-09
  • 2021-08-24
  • 2022-12-23
  • 2021-05-17
相关资源
相似解决方案