本文整理汇总了Java中android.app.AlertDialog.getButton方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.getButton方法的具体用法?Java AlertDialog.getButton怎么用?Java AlertDialog.getButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.getButton方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDisconnectDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
private void showDisconnectDialog()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.title_cancel);
builder.setMessage(R.string.cancel_connection_query);
builder.setNegativeButton(android.R.string.no, this);
builder.setPositiveButton(android.R.string.yes, this);
builder.setOnCancelListener(this);
builder.show();
AlertDialog alert11 = builder.create();
alert11.show();
Button buttonbackground = alert11.getButton(DialogInterface.BUTTON_NEGATIVE);
buttonbackground.setTextColor(Color.RED);
Button buttonbackground1 = alert11.getButton(DialogInterface.BUTTON_POSITIVE);
buttonbackground1.setTextColor(Color.RED);
}
示例2: getEditTextDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
public AlertDialog getEditTextDialog(Context context, String title, final OnClickOkBtnListener mOnClickOkBtnListener) {
this.mContext = context;
et = (EditText) LayoutInflater.from(context).inflate(R.layout.layout_edittext, null);
et.setSingleLine(true);
AlertDialog mAlertDialog = new AlertDialog.Builder(mContext).setTitle(title)
.setView(et)
.setPositiveButton(mContext.getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String input = et.getText().toString();
if (null != mOnClickOkBtnListener) {
mOnClickOkBtnListener.onClickOk(input);
}
}
})
.setNegativeButton(mContext.getString(R.string.cancel), null).show();
Button btn1 = mAlertDialog.getButton(mAlertDialog.BUTTON_POSITIVE);
btn1.setTextColor(context.getResources().getColor(R.color.colorPrimary));
Button btn2 = mAlertDialog.getButton(mAlertDialog.BUTTON_NEGATIVE);
btn2.setTextColor(context.getResources().getColor(R.color.colorPrimary));
return mAlertDialog;
}
示例3: getConfirmCancelDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* @param context
* @param title
* @param mOnClickOkBtnListener
* @return
*/
public AlertDialog getConfirmCancelDialog(Context context, String title, final OnClickOkBtnListener mOnClickOkBtnListener) {
this.mContext = context;
AlertDialog mAlertDialog = new AlertDialog.Builder(mContext).setTitle(title)
.setPositiveButton(mContext.getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (null != mOnClickOkBtnListener) {
if (null == et) {
mOnClickOkBtnListener.onClickOk(null);
} else {
String input = et.getText().toString();
mOnClickOkBtnListener.onClickOk(input);
}
}
}
})
.setNegativeButton(mContext.getString(R.string.cancel), null).show();
Button btn1 = mAlertDialog.getButton(mAlertDialog.BUTTON_POSITIVE);
btn1.setTextColor(context.getResources().getColor(R.color.colorPrimary));
Button btn2 = mAlertDialog.getButton(mAlertDialog.BUTTON_NEGATIVE);
btn2.setTextColor(context.getResources().getColor(R.color.colorPrimary));
return mAlertDialog;
}
示例4: setTypeface
import android.app.AlertDialog; //导入方法依赖的package包/类
private static void setTypeface(TypefaceHelper helper, AlertDialog alertDialog, String typefaceName, int style) {
Button positive = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
Button negative = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
Button neutral = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
TextView message = (TextView) alertDialog.findViewById(android.R.id.message);
if (positive != null) {
helper.setTypeface(positive, typefaceName, style);
}
if (negative != null) {
helper.setTypeface(negative, typefaceName, style);
}
if (neutral != null) {
helper.setTypeface(neutral, typefaceName, style);
}
if (message != null) {
helper.setTypeface(message, typefaceName, style);
}
}
示例5: onStart
import android.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());
}
}
});
}
}
示例6: validateAndUpdateButton
import android.app.AlertDialog; //导入方法依赖的package包/类
private void validateAndUpdateButton() {
AlertDialog d = (AlertDialog) getDialog();
if (d != null) {
Button button = d.getButton(AlertDialog.BUTTON_POSITIVE);
if (button != null) {
button.setEnabled(isValid());
}
}
}
示例7: prepareDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
public void prepareDialog(Dialog dialog, ItemDesc ctxItem)
{
if(aa == null)
{
Log.e(L.TAG, "MoveToAction.prepareDialog() called before createDialog()");
return;
}
ListDesc selectedListDesc = dataViewer.getSelectedList();
dataViewList.clear();
dataViewList.addAll(dataViewer.getListData());
dataViewList.remove(selectedListDesc);
aa.clear();
int selectedId = selectedListDesc.getId();
for(int i = 0; i < dataViewList.size(); i++)
{
ListDesc listDesc = dataViewList.get(i);
if(listDesc.getId() != selectedId)
{
aa.add(listDesc.getLabel());
}
}
aa.notifyDataSetChanged();
AlertDialog alertDialog = (AlertDialog)dialog;
okButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
okButton.setEnabled(selectedItem != null);
this.ctxItem = ctxItem;
}
示例8: doChangeDialogFontColor
import android.app.AlertDialog; //导入方法依赖的package包/类
private static void doChangeDialogFontColor(AlertDialog dialog) {
int piblue = dialog.getContext().getResources().getColor(PIBLUE);
if (dialog.getButton(AlertDialog.BUTTON_NEGATIVE) != null) {
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(piblue);
}
if (dialog.getButton(AlertDialog.BUTTON_NEUTRAL) != null) {
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(piblue);
}
if (dialog.getButton(AlertDialog.BUTTON_POSITIVE) != null) {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(piblue);
}
}
示例9: showDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
protected void showDialog(Bundle state) {
super.showDialog(state);
getEditText().setError(null);
final AlertDialog dialog = (AlertDialog) getDialog();
View positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
positiveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onPositiveButtonClicked();
}
});
}