我创建了自定义Progress Dialogue
。重写属性如setCancelable()
,setCanceledOnTouchOutside()
不适用于我。Android自定义进度对话框 - setCancelable()
public class CustomProgressDialogue extends ProgressDialog {
private final Context context;
public CustomProgressDialogue(Context context) {
super(context);
this.context = context;
getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.progress_view);
}
// Didn't worked
@Override
public void setCancelable(boolean flag) {
super.setCancelable(false);
}
// Didn't worked
@Override
public void setCanceledOnTouchOutside(boolean cancel) {
super.setCanceledOnTouchOutside(false);
}
}
但同时在创建实例后应用相同的属性。
// Worked
progressDialogue = new CustomProgressDialogue(getContext());
progressDialogue.setCancelable(false);
progressDialogue.setCanceledOnTouchOutside(false);
请问有人能解释一下吗?
为什么设置“MetricsProgressDialogue”?而不是'CustomProgressDialogue'? –
对不起,这是一个复制粘贴错误。立即修改 –