import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
public abstract class DialogUtil {
public void showDialog() {
AlertDialog.Builder builder = new Builder(getContext());
// builder.setMessage("确定退出吗?");
builder.setTitle(getMessage());
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doConfirmThings();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doCancelThings();
}
});
builder.show();
}
public abstract CharSequence getMessage();
public abstract Context getContext();
public abstract void doConfirmThings();
public abstract void doCancelThings();
}
对布局要求不是很高时,可以使用它进行快速开发。