I had a progress dialog which was working before kitkat now it does not display the dialog. If i put a debug and stop the program in post execute before the dialog dismiss it show the dialog , which woul imply that the code is working too fast to display the dialog , but this is not true it takes a good time after the dailog dismiss to show the grid view?
Another strange thing , when it did work it displayed the dialog but the circle did not turn or animate.
Any comments gratefully recieved
private class LoadPhoto extends AsyncTask<String, Void, MyPhoneImagesAdapter> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// initialize the dialog
String searchingString = getResources().getString(R.string.searchingString);
String searchMsgString = getResources().getString(R.string.searchMsgString);
m_dialog.setTitle("Searching...");
m_dialog.setMessage("Please wait while loading client photos...");
m_dialog.setIndeterminate(true);
m_dialog.setCancelable(true);
m_dialog.show();
}
@Override
protected MyPhoneImagesAdapter doInBackground(String... params) {
// TODO Auto-generated method stub
// Execution code
// Note we can call a method in the main class but we are running it in
// the asynchronous thread
getPhotos();
return getPhotos();
}
@Override
protected void onPostExecute(MyPhoneImagesAdapter result) {
super.onPostExecute(result);
// Note we can update the UI from the post execute method only note we pass the adapter which
// we created in the do in background
GridView grid = (GridView) getView().findViewById(R.id.photoGrid);
grid.setAdapter(result);
// See: ImageAdapter.java
grid.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
String tst = "Pick";
String sel = path+"/"+clientPhotos[position];
listener.onImageSelected(sel);
}
});
m_dialog.dismiss();
}
Try initializing ProgressDialog
inside the class LoadPhoto
Declare ProgressDialog mProgressDialog;
in LoadPhoto
And use the static method of ProgressDialog
show() as,
mProgressDialog = ProgressDialog.show(MainActivity.this, "Searching...", "Please wait while loading client photos...", true, true);
The reason this happens is because the processor does not have time to update the UI, so you have to do this manually in loop.
I'm not a android developer, but in java, back in the days i would normally use the repaint();
function.
In c# these simple functions help to update the contorls,
textbox1.Invalidate();
textbox1.Update();
textbox1.Refresh();
I beleive java may have similar functions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.