I have a ListFragment that populates a list using a SimpleCursorAdapter. It is using a two pane setup to show the details fragment on the right side.
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
string[] fromColumns = new string[]
{
MinefieldDataProvider.InterfaceConsts.FirstName
};
int[] toControlIds = new int[]
{
Android.Resource.Id.Text1
};
LoaderManager.InitLoader(PersonnelListLoaderId, null, this);
this._adapter = new SimpleCursorAdapter(Activity.ApplicationContext, Android.Resource.Layout.SimpleListItem1, null, fromColumns, toControlIds, CursorAdapterFlags.None);
this.ListAdapter = this._adapter;
}
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
View detailsPane = this.Activity.FindViewById(Resource.Id.item_detail_container);
this._dualPane = (detailsPane != null && detailsPane.Visibility == ViewStates.Visible);
if (savedInstanceState != null)
this._currentPosition = savedInstanceState.GetInt("currentPosition", -1);
if (this._dualPane)
{
this.ListView.ChoiceMode = ChoiceMode.Single;
this.ShowDetails(this._currentPosition);
}
}
However I’m unsure of the “android “way” in which to populate the details pane with the user selection. Do I extract the URI and pass it to the details fragment and then use a new instance of the ContentProvider in the details section? Or do I pass along each individual field that I want to show up in the user interface somehow?
Note that in the details pane the user will be able to edit the information and save it via a button using the ContentProvider.
I ended up using a loader manager in the details fragment and queried there. It’s more self contained that way.