Was PreferenceFragment intentionally excluded from the compatibility package?

Discovering that PreferenceActivity contains deprecated methods (although these are used in the accompanying sample code) The deprecated methods are deprecated as of Android 3.0. They are perfectly fine on all versions of Android, but the direction is to use PreferenceFragment on Android 3.0 and higher. Can anyone tell me whether this was intentional? My guess … Read more

How to hide action bar before activity is created, and then show it again?

Setting android:windowActionBar=”false” truly disables the ActionBar but then, as you say, getActionBar(); returns null. This is solved by: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getActionBar().hide(); setContentView(R.layout.splash); // be sure you call this AFTER requestFeature This creates the ActionBar and immediately hides it before it had the chance to be displayed. But now there is … Read more

How do I add a Fragment to an Activity with a programmatically created content view

It turns out there’s more than one problem with that code. A fragment cannot be declared that way, inside the same java file as the activity but not as a public inner class. The framework expects the fragment’s constructor (with no parameters) to be public and visible. Moving the fragment into the Activity as an … Read more

Animate the transition between fragments

You need to use the new android.animation framework (object animators) with FragmentTransaction.setCustomAnimations as well as FragmentTransaction.setTransition. Here’s an example on using setCustomAnimations from ApiDemos’ FragmentHideShow.java: ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); and here’s the relevant animator XML from res/animator/fade_in.xml: <objectAnimator xmlns:android=”http://schemas.android.com/apk/res/android” android:interpolator=”@android:interpolator/accelerate_quad” android:valueFrom=”0″ android:valueTo=”1″ android:propertyName=”alpha” android:duration=”@android:integer/config_mediumAnimTime” /> Note that you can combine multiple animators using <set>, just as you … Read more

ActionBar text color

Ok, I’ve found a better way. I’m now able to only change the color of the title. You can also tweak the subtitle. Here is my styles.xml: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”MyTheme” parent=”@android:style/Theme.Holo.Light”> <item name=”android:actionBarStyle”>@style/MyTheme.ActionBarStyle</item> </style> <style name=”MyTheme.ActionBarStyle” parent=”@android:style/Widget.Holo.Light.ActionBar”> <item name=”android:titleTextStyle”>@style/MyTheme.ActionBar.TitleTextStyle</item> </style> <style name=”MyTheme.ActionBar.TitleTextStyle” parent=”@android:style/TextAppearance.Holo.Widget.ActionBar.Title”> <item name=”android:textColor”>@color/red</item> </style> </resources>

Why fragments, and when to use fragments instead of activities?

#1 & #2 what are the purposes of using a fragment & what are the advantages and disadvantages of using fragments compared to using activities/views/layouts? Fragments are Android’s solution to creating reusable user interfaces. You can achieve some of the same things using activities and layouts (for example by using includes). However; fragments are wired … Read more

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