本文整理汇总了Java中android.app.AlertDialog.setOnCancelListener方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.setOnCancelListener方法的具体用法?Java AlertDialog.setOnCancelListener怎么用?Java AlertDialog.setOnCancelListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.setOnCancelListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
public Dialog createDialog() {
mAdapter = new ArrayAdapter<String>(CustomizeLaunchersActivity.this, R.layout.add_list_item);
mAdapter.add(getString(R.string.custom_icon_select_picture));
mAdapter.add(getString(R.string.custom_icon_icon_packs));
if (SpecialIconStore.hasBitmap(CustomizeLaunchersActivity.this, mAppClicked.getComponentName(), SpecialIconStore.IconType.Custom)) {
mAdapter.add(getString(R.string.custom_icon_clear_icon));
}
final AlertDialog.Builder builder = new AlertDialog.Builder(CustomizeLaunchersActivity.this);
builder.setTitle(R.string.custom_icon_select_icon_type);
builder.setAdapter(mAdapter, this);
//builder.setInverseBackgroundForced(false);
AlertDialog dialog = builder.create();
dialog.setOnCancelListener(this);
dialog.setOnDismissListener(this);
dialog.setOnShowListener(this);
return dialog;
}
示例2: createDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
private Dialog createDialog() {
if (mDialog != null) return mDialog;
Activity activity = mActivity;
// load main view
final LayoutInflater factory = LayoutInflater.from(activity);
final View dialog = factory.inflate(R.layout.settings_volume_streams, null);
final ViewGroup parent = (ViewGroup) dialog.findViewById(R.id.placeholder);
// local cache
final int[] stringIds = STRING_IDS;
final int length = stringIds.length;
final SeekBar[] seekBars = mSeekBars = new SeekBar[length];
final TextView[] valueViews = mValueViews = new TextView[length];
mVolumes = new int[length];
// add controls for all stream
for (int i=0; i<length; i++) {
View control = factory.inflate(R.layout.row_volume, null);
// init text
TextView text = (TextView) control.findViewById(R.id.text);
text.setText(stringIds[i]);
// init values
valueViews[i] = (TextView) control.findViewById(R.id.value);
// init seekbars
SeekBar seekBar = (SeekBar) control.findViewById(R.id.seekbar);
seekBar.setOnSeekBarChangeListener(this);
seekBar.setId(mIdCounter++); // workaround for seekbar id bug
seekBar.setTag(i);
seekBars[i] = seekBar;
// add to parent
parent.addView(control);
//Log.d(TAG, "create: index: " + i + ", seekbar: " + seekBar);
}
AlertDialog d = new AlertDialog.Builder(activity)
.setIcon(R.drawable.ic_dialog_menu_generic)
.setTitle(R.string.txt_volume)
.setView(dialog)
.setPositiveButton(R.string.btn_set, this)
.setNegativeButton(R.string.btn_calcel, this)
.create();
d.setOnCancelListener(this);
return d;
}
示例3: showError
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* Shows an error message.
*
* @param context
* {@link Context}
* @param msg
* the message.
* @param listener
* will be called after the user cancelled the dialog.
*/
public static void showError(Context context, CharSequence msg,
DialogInterface.OnCancelListener listener) {
AlertDialog dlg = newAlertDlg(context);
dlg.setIcon(android.R.drawable.ic_dialog_alert);
dlg.setTitle(R.string.afc_title_error);
dlg.setMessage(msg);
dlg.setOnCancelListener(listener);
dlg.show();
}
示例4: confirmYesno
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* Shows a confirmation dialog.
*
* @param context
* {@link Context}
* @param msg
* the message.
* @param onYes
* will be called if the user selects positive answer (a
* <i>Yes</i> or <i>OK</i>).
* @param onNo
* will be called after the user cancelled the dialog.
*/
public static void confirmYesno(Context context, CharSequence msg,
DialogInterface.OnClickListener onYes,
DialogInterface.OnCancelListener onNo) {
AlertDialog dlg = newAlertDlg(context);
dlg.setIcon(android.R.drawable.ic_dialog_alert);
dlg.setTitle(R.string.afc_title_confirmation);
dlg.setMessage(msg);
dlg.setButton(DialogInterface.BUTTON_POSITIVE,
context.getString(android.R.string.yes), onYes);
dlg.setOnCancelListener(onNo);
dlg.show();
}