开发者

ProgressDialog wont show onPreExecute in my asynctask?

开发者 https://www.devze.com 2023-03-25 11:45 出处:网络
Ive looked at some questions and non answer the problem im having.. I have this asyncTask... private class LoadData extends AsyncTask<Void, Void, Void>{

Ive looked at some questions and non answer the problem im having..

I have this asyncTask...

  private class LoadData extends AsyncTask<Void, Void, Void>{



    protected Void onPreExecute(Void...arg0){
        super.onPreExecute();

        ProgressDialog dialog = ProgressDialog.show(shoppingClass.this, "", 
                "Loading. Please wait...", true);
        dialog.show();

        return null;

    }
    @Override
    protected Void doInBackground(Void... params) {
        item = we.getText().toString();
        getUserPreference();
       开发者_JAVA技巧 itemLookup.loadUrl(url);
        return null;
    }
    @Override
    protected void onPostExecute(Void notused){
        itemLookup.setVisibility(View.VISIBLE);

    }

}

The problem is the progessDialog is not showing up? I dont know why...Im doing everything write according to the documentation.


You are not overriding correctly the method. Change onPreExecute to this:

@Override
protected void onPreExecute() {
    super.onPreExecute();

     ProgressDialog dialog = ProgressDialog.show(shoppingClass.this, "", 
            "Loading. Please wait...", true);
     dialog.show();
}


it could just be that doinbackground is completing too quickly for you to be able to see the dialog.


Check that shoppingClass.this has the UI context. Also, you shouldn't have to call .show() twice on it and you don't have to return null as its void (lowercase).

0

精彩评论

暂无评论...
验证码 换一张
取 消