Domanda

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);
    }
 }
È stato utile?

Soluzione

You need to call your background thread inside "onCreateView"

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top