进度对话与AsyncTask +抽屉布局无法正常工作

时间:2014-05-28 23:35:23

标签: android android-asynctask progressdialog drawerlayout

我正在一个应用程序中工作,我在活动之间有几个网络请求,所有这些请求显示并正常工作......除了第一个。我的猜测是因为我实现了抽屉布局,并且“阻止”对话......

我在请求之前尝试解除抽屉,但仍然不起作用:(

// This is called when someone clicks in an item from the drawer layout
// "this" is passed and fetched as Context for the ProgressDialog
amr = new AvailableModelRequest(this,ss,this.getFilesDir(), modelType);
... more stuff goes here to handle the result from the Request.

// Inside the AvailableModelRequest...

loader.execute(MESSAGE_TYPE);

// The AsyncTask that handles the network request and showing the dialog
private class DataLoader extends AsyncTask<String, Void, Boolean> {

    ProgressDialog pD = new ProgressDialog(context);

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        Log.i("INSIDE PRE EXECUTE!: ", "HELLO DIALOG!!");
        pD.setTitle("Loading");
        pD.setMessage("Gathering information...");
        pD.setIndeterminate(false);
        pD.setCancelable(false);
        pD.show();
    }

    @SuppressWarnings("unused")
    @Override
    protected Boolean doInBackground(String... message) {
        // Network stuff happens
    }

    /**
     * Look for errors in the server operations
     */
    @Override
    protected void onPostExecute(Boolean success) {
        // do stuff based on the success or not
        pD.dismiss();
    }

我通过应用程序有类似的请求,所有这些请求都很好......除了这一个:(

任何想法我做错了什么?

谢谢!

编辑:所以我采用了Drawer布局,由于某种原因,这个Dialog仍未加载:(

0 个答案:

没有答案