Вопрос

I have implemented the following code to display Contacts as a ListView. MyAdapter extends CursorAdapter.

public class MainActivity extends FragmentActivity implements 
    LoaderManager.LoaderCallbacks<Cursor>{

    private MyAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ListView lv = (ListView)findViewById(R.id.listView_val);
        adapter = new MyAdapter(this, null, 1);
        lv.setAdapter(adapter);

        .....

        getSupportLoaderManager().initLoader(0, null, this);
    } 
        .....
    public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { ..... } ....}

What I want to know is, how does the adapter - mAdapter know that it has to pick the data from the cursor supplied by the CursorLoader (Cursor available after calling onCreateLoader)?

Это было полезно?

Решение

Другие советы

This link provides with detailed example how the cursor adapter loads the data from cursor loader. Pass through next page also in the web link for the full answer. http://developer.android.com/training/load-data-background/setup-loader.html

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top