I just got the pulldown navigation to work with ActionbarSherlock. Here is how it looks like:
And what I am wondering is whether I can put the sharing widget right next to the pulldown on the same action bar? If so, how can I do that? Is it part of the layout xml that I have to add? Or where/what needs to be specified?
This is my values/arrays.xml file
<resources>
<string-array name="locations">
<item>Home</item>
<item>Learn</item>
<item>Services</item>
<item>Next Steps</item>
</string-array>
</resources>
And this is how I start the activity:
private TextView mSelected;
private String[] mLocations;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTheme(R.style.Theme_Sherlock_Light);
But when I try to add both, the sharing and the list-navigation. It doesn't render one or the other. Here is what I try to do:
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(
context, R.array.locations, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
Thanks, Alex
RUNTIME ERROR:
java.lang.ClassCastException: android.widget.ShareActionProvider cannot be cast to com.actionbarsherlock.view.ActionProvider
at com.actionbarsherlock.view.MenuInflater$MenuState.readItem(MenuInflater.java:389)
at com.actionbarsherlock.view.MenuInflater.parseMenu(MenuInflater.java:162)
at com.actionbarsherlock.view.MenuInflater.inflate(MenuInflater.java:112)
at com.marketing.MainActivity.onCreateOptionsMenu(MainActivity.java:880)
at com.actionbarsherlock.app.SherlockActivity.onCreatePanelMenu(SherlockActivity.java:184)
at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559)
at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:65)
at com.actionbarsherlock.app.SherlockActivity.onCreateOptionsMenu(SherlockActivity.java:149)
at android.app.Activity.onCreatePanelMenu(Activity.java:2444)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:388)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739)
at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2833)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)