本文整理汇总了Java中android.app.AlertDialog.Builder.setOnCancelListener方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.setOnCancelListener方法的具体用法?Java Builder.setOnCancelListener怎么用?Java Builder.setOnCancelListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.AlertDialog.Builder
的用法示例。
在下文中一共展示了Builder.setOnCancelListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showAlert
import android.app.AlertDialog.Builder; //导入方法依赖的package包/类
public static AlertDialog showAlert(final Context context, final String title, final String msg, final View view, final DialogInterface.OnClickListener lOk,
final DialogInterface.OnClickListener lCancel) {
if (context instanceof Activity && ((Activity) context).isFinishing()) {
return null;
}
final Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage(msg);
builder.setView(view);
builder.setPositiveButton(R.string.app_ok, lOk);
builder.setNegativeButton(R.string.app_cancel, lCancel);
// builder.setCancelable(true);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (lCancel != null) {
lCancel.onClick(dialog, 0);
}
}
});
final AlertDialog alert = builder.create();
alert.show();
return alert;
}
示例2: noNetworkDialog
import android.app.AlertDialog.Builder; //导入方法依赖的package包/类
private void noNetworkDialog(){
Builder dialogNoNetwork;
dialogNoNetwork = new AlertDialog.Builder(this);
dialogNoNetwork.setCancelable(true);
dialogNoNetwork.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
finish();
}
});
dialogNoNetwork.setTitle(R.string.nonetwork_title);
dialogNoNetwork.setMessage(getString(R.string.nonetwork_message));
dialogNoNetwork.show();
}