例如,我想添加此否定按钮,但是3秒后。
是否可以,或者我必须关闭此progressDialog
并打开一个新对话框?
我尝试过:
final ProgressDialog progressDialog = new ProgressDialog(this,
R.style.Theme_AppCompat_DayNight_Dialog);
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.setMessage("Bla bla bla ...");
progressDialog.show();
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,"NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
progressDialog.dismiss();
}
});
SystemClock.sleep(3000);
progressDialog.show();
答案 0 :(得分:0)
将按钮保持隐藏状态,并在打开对话框后使用此代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./main.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<header>
<Nav >
<div class='logo' onclick="show(event)"><span class="fas fa-igloo"></span></div>
<div class='company'>Company Name</div>
<ul class='list'>
<li><a href="#">Home</a></li>
<li><a href="#">Who are We?</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Contact</a></li>
</ul>
</Nav>
</header>
<script>
function show(){
document.getElementsByClassName('list').classList.add('toggle')
}
</script>
</body>
</html>