ActionBarSherlock - Share Content icon issue

2019-05-11 10:49发布

I am using ActionBarSherlock and have implemented ShareActionProvider.

When a user selects an app to share content with, eg Twitter, the actionbar displays a Twitter icon next to the Share button icon. This stays there forever.

Does anybody know how to disable the application icon from appearing next to the Share button?

2条回答
霸刀☆藐视天下
2楼-- · 2019-05-11 10:59

Found the answer:

Implement OnShareTargetSelectedListener and set it on the ShareActionProvider

public void onCreateOptionsMenu(Menu menu){
    ....
    actionProvider.setOnShareTargetSelectedListener(this);
    ....


 @Override 
 public boolean onShareTargetSelected(ShareActionProvider source, 
         Intent intent) { 

     context.startActivity(intent); 

     // started activity ourself to prevent search history 
     return true; 
 } 
查看更多
Bombasti
3楼-- · 2019-05-11 11:01

The top target is featured in the action bar. This is the behavior of the widget as it exists in Android.

If you do not want this behavior copy the sources into your app and modify its behavior to never display the top target icon.

查看更多
登录 后发表回答