The below copied from the book The Bid nerd ranch
, my question is about private static class
shown below, Can I change private static class RunCursorAdapter
to public class RunCursorAdapter
and move it to another file? will that cause any memory issue when the loader reload when loader re-run for any reason?
public class RunListFragment extends ListFragment implements LoaderCallbacks<Cursor> {
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new RunListCursorLoader(getActivity());
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
RunCursorAdapter adapter =
new RunCursorAdapter(getActivity(), (RunCursor)cursor);
setListAdapter(adapter);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
setListAdapter(null);
}
private static class RunCursorAdapter extends CursorAdapter {
private RunCursor mRunCursor;
public RunCursorAdapter(Context context, RunCursor cursor) {
super(context, cursor, 0);
mRunCursor = cursor;
}
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
}
public void bindView(View view, Context context, Cursor cursor) {
Run run = mRunCursor.getRun();
TextView startDateTextView = (TextView)view;
String cellText = context.getString(R.string.cell_text, run.getStartDate());
startDateTextView.setText(cellText);
}
}
}