本文主要介绍AlertDialog最常用的使用场景,及各个场景的使用方式:
注:此处一般都使用下面的包,下面的包是个兼容包!import android.app.AlertDialog;
1.style① 默认样式
AlertDialog.Builder builder1=new AlertDialog.Builder(DiaLogActivity.this);
//不同写法(因为settitle返回的也是build类型 :
// builder.setTitle("hello");
//builder.setMessage("how are you?");
builder1.setTitle("hello").setMessage("how are you").setIcon(R.drawable.a111)
.setPositiveButton("good", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ToastUtil.showMsg(DiaLogActivity.this,"well done");
}
}).setNeutralButton("just so so", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ToastUtil.showMsg(DiaLogActivity.this,"hihihi"