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