Scr*_*bot 0 android progressdialog android-layout
那
我试过实现它.
mProgressDialog = new ProgressDialog(this);
mProgressDialog.getWindow().setContentView(R.layout.footcloth);
mProgressDialog.setMessage(Constants.PROGRESS_DIALOG_MESSAGE);
mProgressDialog.show();
Run Code Online (Sandbox Code Playgroud)
但是这个代码抛出异常
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
Run Code Online (Sandbox Code Playgroud)
此代码在活动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();
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
而这项活动正在其他方面扩展.所以,请帮我解决我的问题,谢谢)
有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);
}
}
Run Code Online (Sandbox Code Playgroud)在你的活动中使用
TransparentProgressDialog pd = new TransparentProgressDialog(context);
pd.show();
....
if (pd.isShowing()){
pd.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5854 次 |
| 最近记录: |