In my “OnClickListener” the “ProgressDialog” doesn’t appear (code below):
Button suchenbutton = (Button) findViewById(R.id.suchen);
suchenbutton.setOnClickListener(new View.OnClickListener() {
//TODO
public void onClick(View v) {
ProgressDialog dialog= ProgressDialog.show(TankFinderActivity.this, "",
"Loading. Please wait...", true);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(filterTextSSD.getWindowToken(), 0);
loadsuchen();
dialog.dismiss();
}
});
What did I do wrong?
It seems that
loadsuchen()is a heavy method that runs on the main thread. UseAsyncTaskto run that method in a separate thread and calldialog.dismiss()at the end: