本文整理汇总了Java中android.support.v7.app.AlertDialog.getButton方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.getButton方法的具体用法?Java AlertDialog.getButton怎么用?Java AlertDialog.getButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.getButton方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStart
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
final AlertDialog dialog = (AlertDialog) getDialog();
final Button loginButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onLogin(dialog);
}
});
try {
Login login = Stores.login(context).load();
username.setText(login.username);
password.setText(BlackBoxes.decrypt(context, login.password));
onLogin(getDialog());
} catch (NoSuchPreferenceFoundException e) {
Log.e(TAG, "NoSuchPreferenceFoundException: login");
}
}
示例2: onStart
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog != null) {
Button button = alertDialog.getButton(Dialog.BUTTON_NEUTRAL);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
getActivity().startActivityForResult(intent, REQ_SELECT_IMAGE);
}
});
}
}
示例3: confirmLogOut
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void confirmLogOut() {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogStyle);
builder.setTitle(R.string.are_you_sure);
builder.setPositiveButton(R.string.sign_out, (dialog1, whichButton) -> {
});
builder.setNegativeButton(R.string.cancel, (dialog12, whichButton) -> dialog12.dismiss());
AlertDialog dialog = builder.create();
dialog.show();
Button buttonSignOut = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
buttonSignOut.setOnClickListener(
v -> presenter.logout()
);
}
示例4: updateOkButtonState
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void updateOkButtonState(AlertDialog dialog, EditText editText) {
Button buttonOK = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (editText == null || (editText.getText().toString().trim()).length() == 0) {
buttonOK.setEnabled(false);
return;
}
if (mTitle != null && !mTitle.equalsIgnoreCase(editText.getText().toString().trim())) {
buttonOK.setEnabled(true);
} else {
editText.setError(getActivity().getString(R.string.err_no_edit));
buttonOK.setEnabled(false);
}
}
示例5: onStart
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
AlertDialog dialog = (AlertDialog) getDialog();
// http://stackoverflow.com/a/16972670/1048340
//noinspection ConstantConditions
dialog.getWindow()
.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
// Do not dismiss the dialog when clicking the neutral button.
Button neutralButton = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
if (neutralButton != null) {
neutralButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rootView.removeAllViews();
switch (dialogType) {
case TYPE_CUSTOM:
dialogType = TYPE_PRESETS;
((Button) v).setText(
customButtonStringRes != 0 ? customButtonStringRes : R.string.cpv_custom);
rootView.addView(createPresetsView());
break;
case TYPE_PRESETS:
dialogType = TYPE_CUSTOM;
((Button) v).setText(
presetsButtonStringRes != 0 ? presetsButtonStringRes : R.string.cpv_presets);
rootView.addView(createPickerView());
}
}
});
}
}
示例6: onCreateDialog
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final LayoutInflater inflater = LayoutInflater.from(getActivity());
// Read button configuration
final Bundle args = getArguments();
final int index = args.getInt(ARG_INDEX);
final String command = args.getString(ARG_COMMAND);
final int eol = args.getInt(ARG_EOL);
final int iconIndex = args.getInt(ARG_ICON_INDEX);
final boolean active = true; // change to active by default
mActiveIcon = iconIndex;
// Create view
final View view = inflater.inflate(R.layout.feature_uart_dialog_edit, null);
final EditText field = mField = (EditText) view.findViewById(R.id.field);
final GridView grid = (GridView) view.findViewById(R.id.grid);
final CheckBox checkBox = mActiveCheckBox = (CheckBox) view.findViewById(R.id.active);
checkBox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
field.setEnabled(isChecked);
grid.setEnabled(isChecked);
if (mIconAdapter != null)
mIconAdapter.notifyDataSetChanged();
}
});
final RadioGroup eolGroup = mEOLGroup = (RadioGroup) view.findViewById(R.id.uart_eol);
switch (Command.Eol.values()[eol]) {
case CR_LF:
eolGroup.check(R.id.uart_eol_cr_lf);
break;
case CR:
eolGroup.check(R.id.uart_eol_cr);
break;
case LF:
default:
eolGroup.check(R.id.uart_eol_lf);
break;
}
field.setText(command);
field.setEnabled(active);
checkBox.setChecked(active);
grid.setOnItemClickListener(this);
grid.setEnabled(active);
grid.setAdapter(mIconAdapter = new IconAdapter());
// As we want to have some validation we can't user the DialogInterface.OnClickListener as it's always dismissing the dialog.
final AlertDialog dialog = new AlertDialog.Builder(getActivity()).setCancelable(false).setTitle(R.string.uart_edit_title).setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null).setView(view).show();
final Button okButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
okButton.setOnClickListener(this);
return dialog;
}
示例7: onCreateDialog
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
@NonNull
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Context context = getActivity();
final Bundle args = getArguments();
final String oldName = args.getString(NAME);
final boolean duplicate = args.getBoolean(DUPLICATE);
final int titleResId = duplicate || oldName == null ? R.string.uart_new_configuration_title : R.string.uart_rename_configuration_title;
final LayoutInflater inflater = LayoutInflater.from(getActivity());
final View view = inflater.inflate(R.layout.feature_uart_dialog_new_configuration, null);
final EditText editText = mEditText = (EditText) view.findViewById(R.id.name);
editText.setText(args.getString(NAME));
final View actionClear = view.findViewById(R.id.action_clear);
actionClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
editText.setText(null);
}
});
final AlertDialog dialog = new AlertDialog.Builder(context).setTitle(titleResId).setView(view).setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok, null).setCancelable(false).show(); // this must be show() or the getButton() below will return null.
final Button okButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
okButton.setOnClickListener(this);
return dialog;
}
示例8: onStart
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override public void onStart() {
super.onStart();
AlertDialog dialog = (AlertDialog) getDialog();
// http://stackoverflow.com/a/16972670/1048340
//noinspection ConstantConditions
dialog.getWindow()
.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
// Do not dismiss the dialog when clicking the neutral button.
Button neutralButton = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
if (neutralButton != null) {
neutralButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
rootView.removeAllViews();
switch (dialogType) {
case TYPE_CUSTOM:
dialogType = TYPE_PRESETS;
((Button) v).setText(R.string.cpv_custom);
rootView.addView(createPresetsView());
break;
case TYPE_PRESETS:
dialogType = TYPE_CUSTOM;
((Button) v).setText(R.string.cpv_presets);
rootView.addView(createPickerView());
}
}
});
}
}