我創建了自定義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'? –
對不起,這是一個複製粘貼錯誤。立即修改 –