Importing google-play-services lib into Intellij IDEA 12 (and 13)

For historical reasons, I’m going to reproduce what I did, taken from here. Many thanks to @Hesam who found it. I will vote to close the whole question. Note: the shortcuts are for OS X and Intellij 12 and 13. Make sure you have the latest SDK/ADT Tools and the play services. They change every … Read more

Change ActionBarSherlock background color

The action bar background color is defined in a style for the action bar, not in the theme itself. You’ll need to do something like this: <style name=”Theme.MyTheme” parent=”Theme.Sherlock.ForceOverflow”> <item name=”actionBarStyle”>@style/Widget.MyTheme.ActionBar</item> <item name=”android:actionBarStyle”>@style/Widget.MyTheme.ActionBar</item> </style> <style name=”Widget.MyTheme.ActionBar” parent=”Widget.Sherlock.ActionBar”> <item name=”android:background”>#ff000000</item> <item name=”background”>#ff000000</item> </style> Be careful using colors defined in XML. ColorDrawable did not respect it’s view … Read more

InflateException: Couldn’t resolve menu item onClick handler

I found a solution that worked for me. Usually the onClick attribute in a layout has the following method public void methodname(View view) { // actions } On a menu item (in this case Sherlock menu) it should follow the following signature: public boolean methodname(MenuItem item) { // actions } So, your problem was that … Read more

Preferences screen using ActionBar Sherlock

onBuildHeaders() will only be called if you are running on API Level 11 or higher. On older devices, you are back to the classic addPreferencesFromResource() approach. See this sample project for an example of supporting PreferenceFragment on API Level 11+ and classic preferences on older versions of Android. Specifically, its SherlockFragmentActivity looks like: package com.commonsware.android.preffragsbc; … Read more

ActionBar – custom view with centered ImageView, Action Items on sides

If you want imageview in Center of ActionBar then use: just replace getActionBar(); to getSupportActionBar(); in below code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.actionbar_custom_view_home); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowCustomEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } your actionbar_custom_view_home.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:gravity=”center” … Read more

Setting ActionBarSherlock Theme for Android app

Usually, you set your theme in the manifest, as shown in the Android developer documentation (and linked to from the ActionBarSherlock theming page). If you want to use ActionBarSherlock everywhere within your app, this works: <application android:icon=”@drawable/ic_launcher” android:label=”@string/app_name” android:theme=”@style/Theme.Sherlock”>