Code example for LoaderManager

Methods: initLoader

0
    public RosterOnlineAdapter(Activity context, LoaderManager loaderManager) {
        super(context, null, 0x00);
        this.context = context;
        this.inflater = context.getLayoutInflater();
        // Initialize loader for online Id. 
        loaderManager.initLoader(ADAPTER_ONLINE_ID, null, this);
    } 
 
    @Override 
    public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
        return new CursorLoader(context, Settings.BUDDY_RESOLVER_URI, null,
                GlobalProvider.ROSTER_BUDDY_STATUS + "!='" + StatusUtil.STATUS_OFFLINE + "'", null, 
                GlobalProvider.ROSTER_BUDDY_NICK + " ASC"); 
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
        // Detecting columns. 
        COLUMN_ROSTER_BUDDY_ID = cursor.getColumnIndex(GlobalProvider.ROSTER_BUDDY_ID);
        COLUMN_ROSTER_BUDDY_NICK = cursor.getColumnIndex(GlobalProvider.ROSTER_BUDDY_NICK);
Experience pair programming with AI  Get Codota for Java