本文整理匯總了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();
}