UnsupportedOperationException: Can’t convert to dimension: type=0x1

After 2 days I found the solution; from the layout as defined in my question, I have a Spinner which is bound with a custom TextView: <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/listTextViewSpinner” … android:textSize=”@dimen/spinner_list_item_text_size” … /> Here, I have an extracted dimension resource: @dimen/spinner_list_item_text_size. This has been defined in dimens.xml in the following directories: values-sw600dp … Read more

Getting the error “Java.lang.IllegalStateException Activity has been destroyed” when using tabs with ViewPager

This seems to be a bug in the newly added support for nested fragments. Basically, the child FragmentManager ends up with a broken internal state when it is detached from the activity. A short-term workaround that fixed it for me is to add the following to onDetach() of every Fragment which you call getChildFragmentManager() on: … Read more

Actionbar notification count icon (badge) like Google has

I am not sure if this is the best solution or not, but it is what I need. Please tell me if you know what is need to be changed for better performance or quality. In my case, I have a button. Custom item on my menu – main.xml <item android:id=”@+id/badge” android:actionLayout=”@layout/feed_update_count” android:icon=”@drawable/shape_notification” android:showAsAction=”always”> </item> … Read more

Difference between ActionBarSherlock and ActionBar Compatibility

ActionBarSherlock vs ActionBarCompat: I Just want to put few code difference between ActionBarSherlock vs ActionBarCompat Lib We can migrate some apps from ActionBarSherlock to ActionBarCompat: steps: Import AppCompat project. Replace SherlockFragmentActivity with ActionBarActivity. Replace SherlockFragment with Fragment. Change Menu, MenuItem and getSupportMenuInflater() references. Modify the way you get Action Views. mSearchView = (SearchView)MenuItemCompat.getActionView(mSearchItem) Modify your … Read more

Remove shadow below actionbar

What is the style item to make it disappear? In order to remove the shadow add this to your app theme: <style name=”MyAppTheme” parent=”android:Theme.Holo.Light”> <item name=”android:windowContentOverlay”>@null</item> </style> UPDATE: As @Quinny898 stated, on Android 5.0 this has changed, you have to call setElevation(0) on your action bar. Note that if you’re using the support library you … Read more

Fragment MyFragment not attached to Activity

I’ve found the very simple answer: isAdded(): Return true if the fragment is currently added to its activity. @Override protected void onPostExecute(Void result){ if(isAdded()){ getResources().getString(R.string.app_name); } } To avoid onPostExecute from being called when the Fragment is not attached to the Activity is to cancel the AsyncTask when pausing or stopping the Fragment. Then isAdded() … Read more