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

Spinner : onItemSelected not called when selected item remains the same

Ok, I finally found a solution, by creating my own class extending Spinner : public class MySpinner extends Spinner { OnItemSelectedListener listener; public MySpinner(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void setSelection(int position) { super.setSelection(position); if (listener != null) listener.onItemSelected(null, null, position, 0); } public void setOnItemSelectedEvenIfUnchangedListener( OnItemSelectedListener listener) { this.listener = … Read more

android:actionBarStyle requires API level 11

Another option is to use the tools:targetApi attribute, which requires the tools namespace. This acts in a similar fashion to the @TargetApi annotation you can use in java files. <resources xmlns:tools=”http://schemas.android.com/tools”> <style name=”MyThemes.MyTheme”> <item name=”actionBarStyle”>@style/Widget.Styled.ActionBar</item> <item name=”android:actionBarStyle” tools:targetApi=”11″>@style/Widget.Styled.ActionBar</item> </style> </resources> Note the xmlns:tools=”http://schemas.android.com/tools” in the <resources> tag, as it is required.

Android Viewpager as Image Slide Gallery

In Jake’s ViewPageIndicator he has implemented View pager to display a String array (i.e. [“this”,”is”,”a”,”text”]) which you pass from YourAdapter.java (that extends FragmentPagerAdapter) to the YourFragment.java which returns a View to the viewpager. In order to display something different, you simply have to change the context type your passing. In this case you want to … Read more

Transparent Actionbar: custom tabcolor

Call setStackedBackgroundDrawable() on your ActionBar: getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); ActionBar actionBar = getActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(“#330000ff”))); actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor(“#550000ff”))); This produces (as an example with some random icons and tabs, and two different bluish background colors to highlight the effect): (The refresh icon is the default one, which comes with a slight transparency. The other icons are custom test icons … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)