3

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?

Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106
tiptopjat
  • 499
  • 3
  • 13
  • 24

2 Answers2

6

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; 
 } 
tiptopjat
  • 499
  • 3
  • 13
  • 24
2

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.

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • Where are the sources for ActionBar? – tiptopjat Jun 17 '12 at 10:56
  • Possible solution here, trying it now. https://groups.google.com/forum/?hl=en&fromgroups#!topic/actionbarsherlock/u280feVExcI – tiptopjat Jun 17 '12 at 10:57
  • The main reason I would like to remove the application icon is because the icons have a grey border, which doesn't match my black actionbar. (http://imageshack.us/photo/my-images/155/20120617130029.jpg/). Do you know how I can change this from black to grey? I would be happy to keep the app icon on the action bar if I could change the grey colour. – tiptopjat Jun 17 '12 at 12:58