gpt4 book ai didi

android - 在 Fragment 类中显示 ProgressDialog

转载 作者:IT老高 更新时间:2023-10-28 21:54:11 26 4
gpt4 key购买 nike

我试图在 Fragment 类中显示 ProgressDialog。以下代码仅适用于 Activity 类,但不适用于 Fragment。有人可以帮我解决这个问题,为什么这个 ProgressDialog 实现只适用于 Activity 而不适用于 Fragment

private class ProcessUpdateProfile extends
AsyncTask<String, String, JSONObject> {

private ProgressDialog nDialog;

@Override
protected void onPreExecute() {
super.onPreExecute();
nDialog = new ProgressDialog(PFragment.this); //Here I get an error: The constructor ProgressDialog(PFragment) is undefined
nDialog.setMessage("Loading..");
nDialog.setTitle("Checking Network");
nDialog.setIndeterminate(false);
nDialog.setCancelable(true);
nDialog.show();

}
}

最佳答案

Fragment

中试试这个
 nDialog = new ProgressDialog(getActivity()); 

关于android - 在 Fragment 类中显示 ProgressDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24825114/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com