How to get text on an ActionBar Icon?

Here is some example code that worked for me. 1: Create a layout for your badge menu item. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”48dp” android:layout_height=”fill_parent” android:layout_gravity=”right” > <!– Menu Item Image –> <ImageView android:layout_width=”48dp” android:layout_height=”fill_parent” android:clickable=”true” android:src=”https://stackoverflow.com/questions/13288989/@drawable/bkg_actionbar_notify_off” /> <!– Badge Count –> <TextView android:id=”@+id/actionbar_notifcation_textview” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentRight=”true” android:padding=”@dimen/padding_small” android:text=”99″ android:textColor=”@color/holo_orange_dark” /> </RelativeLayout> 2: Create a menu item in …

Read more

Android ActionBar Customize Search View

I did a class SearchViewFormatter to format easily the native SearchView android widget. An example: new SearchViewFormatter() .setSearchBackGroundResource(R.drawable.my_bg) .setSearchIconResource(R.drawable.my_ic, true, false) //true to icon inside edittext, false to outside .setSearchVoiceIconResource(R.drawable.my_ic) .setSearchTextColorResource(R.color.my_color) .setSearchHintColorResource(R.color.my_color) .setSearchCloseIconResource(R.drawable.my_ic) .setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) .format(mSearchView);

ActionBarSherlock – The type android.support.v4.app.Fragment cannot be resolved. It is indirectly referenced from required .class files

I had the same problem as you since I had updated the SDK. I have solved my problem by doing this (on eclipse) : Right click on the action bar sherlock library => Properties => Java Build Path => Order and Export tab => check android support v4 or Android Private Libraries and select Ok …

Read more

showAsAction=”ifRoom” doesn’t show the item even when there is plenty of room

It is really not a big fat lie but a small oversight. The showAsAction attribute must be defined using a different namespace “http://schemas.android.com/apk/res-auto” You should therefore in your top menu tag define a namespace as follows xmlns:app=”http://schemas.android.com/apk/res-auto” and then use that to define your showAsAction attribute like so app:showAsAction=”ifRoom” That should fix it

Put a progressBar on ActionBar

NOTE: The functionality below is now deprecated in the Support Library. You need to call requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) in your onCreate() before setting the activity’s layout: e.g. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); … // set layout etc If you are using the support library replace requestWindowFeature with supportRequestWindowFeature And then call setProgressBarIndeterminateVisibility(true); on your …

Read more