nullnullSetting Up the Loader 设置装载机

在写这篇文章之前,xxx已经写过了几篇关于改nullnull主题的文章,想要了解的朋友可以去翻一下之前的文章

    You create a CursorLoader within a loader framework. To set up the framework, you implement theLoaderCallbacks<Cursor> as part of an Activity. In addition, to provide compatibility compatible with platform versions starting with Android 1.6, you must extend theActivity with the FragmentActivity class. http://blog.csdn.net/sergeycao

    Note: A Fragment is not a prerequisite forCursorLoader. As a convenience, the support library classFragmentActivity contains the fragment and the loader frameworks, but they are completely independent of each other.

    Before you can use the loader framework, you need to initialize it. To do this, retrieve aLoaderManager object and call its initLoader() method.

    If you do use one or more Fragment objects in an Activity, the LoaderManager you retrieve is available to all of them.

    

Extend an Activity

    每日一道理
只有启程,才会到达理想和目的地,只有拼搏,才会获得辉煌的成功,只有播种,才会有收获。只有追求,才会品味堂堂正正的人。

    To set up an Activity subclass to contain a CursorLoader, extend the subclass with must extend FragmentActivity, which provides the loader framework, and implement theLoaderCallbacks<Cursor> interface, which specifies method signatures that the loader framework uses to interact with theActivity.

    For example:

public class DisplayActivity extends FragmentActivity
        implements LoaderManager.LoaderCallbacks<Cursor>

    

Retrieve a LoaderManager

    To get an instance LoaderManager for use in your Activity, call FragmentActivity.getSupportLoaderManager() at the beginning of theonCreate() method. For example:

private LoaderManager mLoaderManager;
public void onCreate() {
...
mLoaderManager = this.getSupportLoaderManager();

    

Initialize the Loader Framework

    Once you have the LoaderManager object, initialize it by callinginitLoader(). For example:

// CursorLoader instance identifier
public static final int URL_LOADER = 0;
...
// Initializes the CursorLoader
getSupportLoaderManager().initLoader(URL_LOADER, null, this);

文章结束给大家分享下程序员的一些笑话语录: 苹果与谷歌之争就是封闭收费与自由免费思想之争。(别急着把google来膜拜哦?那可是一家公司,以赚钱为目标的公司!当年我Party就是这样把广大劳动人民吸引过来的。今天的结果你们都看到了。)

posted @ 2013-05-09 20:38  坚固66  阅读(141)  评论(0编辑  收藏  举报