那
我尝试过实施它。
mProgressDialog = new ProgressDialog(this);
mProgressDialog.getWindow().setContentView(R.layout.footcloth);
mProgressDialog.setMessage(Constants.PROGRESS_DIALOG_MESSAGE);
mProgressDialog.show();
但是此代码抛出异常
java.lang.RuntimeException: Unable to start activity ComponentInfo{im.anticafe.anticafeim/im.anticafe.anticafeim.activities.HomeActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
此代码在活动BottomBarActivity
中实现abstract public class BottomBarActivity extends AppCompatActivity implements View.OnClickListener {
private static final String TAG = "bottomBarActivity";
private int mWidth;
private ProgressDialog mProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
...
mProgressDialog = new ProgressDialog(this);
mProgressDialog.getWindow().setContentView(R.layout.footcloth);
mProgressDialog.setMessage(Constants.PROGRESS_DIALOG_MESSAGE);
mProgressDialog.show();
...
}
...
}
此活动在其他活动中得到扩展。 所以,请帮我解决我的问题,请) 感谢)
答案 0 :(得分:5)
有2个答案
完成重新加载后,您可以再次切换回或另一个片段
如果您想更改进度对话框
public class TransparentProgressDialog extends Dialog {
public TransparentProgressDialog(Context context) {
super(context, R.style.TransparentProgressDialog);
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
wlmp.gravity = Gravity.CENTER_HORIZONTAL;
getWindow().setAttributes(wlmp);
setTitle(null);
setCancelable(false);
setOnCancelListener(null);
View view = LayoutInflater.from(context).inflate(
R.layout.progress_dialog, null);
setContentView(view);
}
}
在您的活动中使用
TransparentProgressDialog pd = new TransparentProgressDialog(context);
pd.show();
....
if (pd.isShowing()){
pd.dismiss();
}