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