HGPB
HGPB

Reputation: 4366

Custom cursor adapter, custom view and cursor loader

Is it possible to to use a cursor loader with a custom view (NOT A LIST VIEW)?

Here is an example of a custom cursor adapter with a list view:

mMyCursorAdapter = new MyAdapterCursor(getActivity(), null, 0);
setListAdapter(mMyCursorAdapter);
getLoaderManager().initLoader(0, null, this);

Instead of a list view I want to populate a custom view. The cursor will bring back one record which will populate the view.

How do I go about this?

Upvotes: 1

Views: 1776

Answers (1)

Khantahr
Khantahr

Reputation: 8518

You don't need an adapter to do that, just get the data out of the Cursor directly and populate the view with it.

For example:

TextView tv = (TextView)findViewById( R.id.my_text_view );
tv.setText( myCursor.getString( myCursor.getColumnIndex( "string_column" ) ) );

Ideally you'd do this in onLoadFinished, where it will happen once your CursorLoader is done loading the data.

Upvotes: 2

Related Questions