Using the Android Support Library


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.)

  1. 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.)
  2. When you need to declare an Activity to use Fragment, you should declare the class derived from “FragmentActivity” instead of “Activity”.
  3. Instead of the method getFragmentManager() , use the method FragmentActivity.getSupportFragmentManager().
  4. 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.

[Related article]
Android Support Library


Your email address will not be published.