我正在顯示服務中的AlertDialog
。問題是,我想在我的AlertDialog
中添加ProgressBar
(圓形)。我該怎麼做呢?我試圖用ProgressDialog
替換AlertDialog
,但它會強制關閉,我知道這是不正確的方式反正。如何在我的alertdialog中添加一個圓形的進度條?
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:我要在服務中做到這一點,而無需使用任何額外的佈局。
服務不應該顯示對話框。我很驚訝它甚至爲你工作。無論如何,用戶界面無論如何都不會是主題。相反,我建議你展示一個通知,它可能會啓動一個對話主題活動。 – BladeCoder
@BladeCoder難怪你會這麼說。你看的樣子。我可以告訴你很聰明:) – user8069029