这是我正在使用的课程
public class ContactsXmpp extends SherlockFragmentActivity {
private static Context ctx;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contacts_xmpp_sip);
ctx = this;
}
当我从此方法调用 asynctask 时出现错误。这是错误
No enclosing instance of type ContactsXmpp is accessible. Must qualify the allocation with an enclosing instance of type ContactsXmpp (e.g. x.new A() where x is an instance of ContactsXmpp).
private static void alert( String str, final String name ) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
alertDialogBuilder.setMessage(str + ": " + name);
alertDialogBuilder.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
Subscription(name);
new ColorsXMPP_AfterLogin().execute(); ///** error getting here..
}
});
alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
unSubscribe(name);
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
异步任务在这里
public class ColorsXMPP_AfterLogin extends AsyncTask<AfterLogging, Void, Void> {
private ProgressDialog _dialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
Log.e(TAG, " GmailXMPP_AfterLogin onPreExecute" );
}
@Override
protected void onPostExecute(Void feed) {
//ProgressBar_hide();
_dialog.dismiss();
Log.e(TAG, " GmailXMPP_AfterLogin onPostExecute" );
}
@Override
protected Void doInBackground(AfterLogging... arg0) {
Log.e(TAG, " GmailXMPP_AfterLogin doInBackground" );
return null;
}
}