Can someone tell me what wrong with my code ? I want to call the ProgressDialog during loading the subject details.

Here is part of the whole code.

public class ScheduleFragment extends Fragment {
/*    others activity    */

public ProgressDialog pDialog;

// Loading subject in Background Thread
    new LoadAllSubject(getActivity()).execute();


class LoadAllSubject extends AsyncTask<String, String, String> {


    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = ProgressDialog.show(ScheduleFragment.this, "Progress", "Loading subjects. Please wait...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
    }
 }
有帮助吗?

解决方案

You need to call your background thread inside "onCreateView"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top