1,实现效果
2,实现逻辑:
【1】创建AlertDialog,设置它的setPositiveButton,setNegativeButton,setOnCancelListener,最后注意要 builder.show();
【2】实现代码:
private void showUpdateDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("版本更新提示");
//mDesc "desc": "有新版本,赶紧下载,有惊喜",
builder.setMessage(mDesc);
// 设置正按钮
builder.setPositiveButton("立刻更新",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//下载apk
downloadApk();
}
});
// 设置负按钮
builder.setNegativeButton("稍后在说", new DialogInterface.OnClickListene