I have some data I load into the database the first time a user enters my Activity
, and want to show a ProgressDialog
while this data is loaded for the first time. My Activity is an ExpandableListActivity
and I don't create the SimpleExpandableListAdapter
or call setListAdapter
passing my adapter until I'm sure the data is actually there. My onCreate
looks like this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCategoryDbHelper = new CategoryDBHelper(this);
// Build default categories... if not there yet
CategoryDbBuilder builder = new CategoryDbBuilder(this);
if (!builder.hasCategoriesInTable()) {
showDialog(PROGRESS_DIALOG_ID);
builder.fillDbWithDefaultCategories();
removeDialog(PROGRESS_DIALOG_ID);
}
populate();
}
I've overwritten onCreateDialog
as such:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case PROGRESS_DIALOG_ID: {
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Loading categories for the first time. Please wait...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
return dialog;
}
}
return null;
}
The populate()
method reads the database and sets up my list adapter, then calls setListAdapter
.
This seems like it should be simple, but it's turning out to be a huge pain. Any help would be appreciated. :-)