Previously, in the article Android Support Library, I wrote about how to set “Support Library”.
With the “Support Library”, you will be able to create an application using the new API even on older platforms. However, when you use the code for the Fragment which is covered in Google Developers site, etc., as it is, you may result in errors.
Here, I list notes simply. (For more information, please refer to Using the v4 Library APIs.)
- If you use a class of the “Support Library”, import the package defined in “android.support”, instead of the native ones. (When you view the candidates of “import” package in Eclipse, two candidate should be displayed.)
- When you need to declare an Activity to use Fragment, you should declare the class derived from “FragmentActivity” instead of “Activity”.
- Instead of the method getFragmentManager() , use the method FragmentActivity.getSupportFragmentManager().
- Instead of the method getLoaderManager() , use the method FragmentActivity.getSupportLoaderManager().
Because there is no direct relationship between the fact “2” and to use Fragment,
you tend to overlook the fact. So you should pay special attention.
Android Support Library