In meiner Anwendung habe ich eine Listenansicht und jedes Element hat einen Knopf. Wenn der Benutzer auf die Schaltfläche klickt, möchte ich eine HTTP-Verbindung ausführen. Also verwende ich AsyncTask in der Adapterklasse. Jetzt wird das Problem Fortschrittsdialog nicht angezeigt.Android: ProgressDialog nicht in Adapter Klasse zeigt
private class MyClass extends AsyncTask<Void, Long, Boolean> {
private Context context;
private ServerCall call = new ServerCall();
private ProgressDialog progressDialog1;
public MyClass(Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
try {
progressDialog1 = ProgressDialog.show(context, "",
"Please wait...", true);
progressDialog1.setIndeterminate(true);
} catch (final Throwable th) {
}
}
@Override
protected void onProgressUpdate(Long... values) {
super.onProgressUpdate(values);
}
@Override
protected Boolean doInBackground(Void... params) {
//some tasks
return true;
}
@Override
protected void onPostExecute(Boolean result) {
if (mode.equalsIgnoreCase("History")) {
Intent order = new Intent(context, ActicityA.class);
order.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(order);
} else {
Intent order = new Intent(context, ActivityB.class);
order.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(order);
}
}
}
wurde onPreExcute() -Methode aufgerufen? Wir brauchen mehr Informationen. –
@LazyNinja ja onPreExcute() aufgerufen. Ich sehe es in Lagcat – Sridhar
Warum protokollieren Sie nicht die Ausnahme im catch-Block innerhalb der PreExecute-Methode. Wenn Sie dort eine Ausnahme erhalten, werden Sie wissen, was das Problem ist. – Sameer