我正在从服务中显示AlertDialog
。问题是,我想在ProgressBar
中添加AlertDialog
(循环)。我该怎么做呢?我尝试用AlertDialog
替换ProgressDialog
,但它会强制关闭,我知道这不是正确的方法。
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("APP IS OBSOLETE")
.setMessage("To continue, please wait for the updates to download.")
.setCancelable(false)
.setPositiveButton("no, thanks", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.exit(0);
}
});
AlertDialog alert = builder.create();
alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
alert.show();
PS:我想在服务中执行此操作,而不使用任何其他布局。
答案 0 :(得分:0)
您仍应使用AlertDialog
,但要更改其显示的View
。
https://developer.android.com/reference/android/app/Dialog.html#setContentView(android.view.View)
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(R.layout.my_progress_view)
...
在构建器上使用此方法:https://developer.android.com/reference/android/app/AlertDialog.Builder.html#setView(int)
R.layout.my_progress_view
是一个包含ProgressBar
的XML文件(您创建它的方式与创建活动布局的方式相同)
答案 1 :(得分:0)
您应该使用dialog.getContext()代替上下文
Matrix_B$Results <- ifelse((Matrix_A$R %in% Matrix_B$R) &
(Matrix_A$NS %in% Matrix_B$NS),1,0))