Error implementing Support Library Action Bar

So, how I solved this problem: Import support library as a project from “sdk/extras/android/support/v7/appcompat”. Reference library in your project (for Eclipse, “Properties – Android – Add”). Build projects (for Eclipse, “Projects – Build All”). Make sure, you have “android.support.v7.appcompat” in your main project gen folder. If it doesn’t worked – clean and rebuild project.

How do you turn off share history when using ShareActionProvider?

For me, the best solution for avoid the history icon is don’t use ShareActionProvider, instead of it, create it as any other action: <item android:id=”@+id/menu_action_share” android:showAsAction=”ifRoom” android:icon=”@drawable/ic_action_share” android:title=”@string/share”/> at the menu/activity_actions.xml put a item with the ic_action_share icon… @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_actions, menu); return super.onCreateOptionsMenu(menu); } Inflate the menu normally… private void … Read more

Proper way to handle action bar up button?

Have you also tried this (taken from Android website here) : in the manifest, for each activity X that needs to go to the main activity, add this to the code: @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Respond to the action bar’s Up/Home button case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; } return … Read more

How to add dividers between specific menu items?

You should use action layout <menu xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” tools:context=”.LandingActivity”> <item android:id=”@+id/action_cart” android:title=”cart” android:actionLayout=”@layout/cart_update_count” android:icon=”@drawable/shape_notification” app:showAsAction=”always”/> </menu> and then the action layout can have the textview with divider. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:orientation=”vertical”> <View android:id=”@+id/divider” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@drawable/divider”/> <TextView android:id=”@android:id/text” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”?android:attr/selectableItemBackground” android:gravity=”center_vertical” android:textAppearance=”?attr/textAppearanceListItemSmall”/> </LinearLayout> then you can add the click listener in code

How can I detect a click on the ActionBar title?

The title is non-clickable AFAIK. The icon/logo is clickable — you’ll get that via android.R.id.home in onOptionsItemSelected(). Conceivably, the title also routes this way, though they don’t mention it and I wouldn’t rely upon it. It sounds like you want a Spinner for the user to choose the actions to execute. If so, use setListNavigationCallbacks(). … Read more

Android action bar like twitter sample

Yet another action bar implementation can be found here (shameless plug), https://github.com/johannilsson/android-actionbar. It’s implemented as a library project so there’s no need to copy-paste resources. Implementation wise it’s built as a widget that extends a RelativeLayout with it own layout for the actions and the bar. This makes it possible to add it to layouts … Read more

OnCreateView called multiple times / Working with ActionBar and Fragments

When you call FragmentTransaction.replace(…), Android will effectively perform a sequence of FragmentTransaction.remove(…) (for all Fragments currently added to that container) and FragmentTransaction.add(…) (for your supplied Fragment). Removing a Fragment from the FragmentManager will cause the Fragment to be destroyed and its state will no longer be managed. Most noticeably, when you re-add the Fragment all … Read more