本文整理汇总了Java中android.app.AlertDialog.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.Builder方法的具体用法?Java AlertDialog.Builder怎么用?Java AlertDialog.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConnection
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* Para debug.
* @param activity
* @param context
*/
public void createConnection(Activity activity, Context context){
try{
dataOpenHelper = new DataOpenHelper(activity);
connection = dataOpenHelper.getWritableDatabase();
Toast.makeText(context, "Conexão com o banco bem sucedida", Toast.LENGTH_SHORT).show();
}
catch (SQLException e) {
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
alert.setTitle(R.string.title_erro);
alert.setMessage(e.getMessage());
alert.setNeutralButton("Que Merda!", null);
alert.show();
}
}
示例2: onCreateDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (isBuilder() && getLayoutId() != 0) {
view = getActivity().getLayoutInflater().inflate(getLayoutId(), null);
}
// 绑定ButterKnife
unbinder = ButterKnife.bind(this, view);
// 创建AlertDialog
AlertDialog.Builder dialog = builder();
if (isBuilder() && getLayoutId() != 0) {
dialog.setView(view);
}
// 拆分系统onCreateDialog方法,提供一个create方法,基本初始化代码放到onCreateDialog执行,对于子类的初始化放到create方法执行
this.create(savedInstanceState, view);
return dialog.create();
}
示例3: ActivateReadMeDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
public void ActivateReadMeDialog(Activity activity , Context context,int Language){
AlertDialog.Builder mReadMeBuilder = new AlertDialog.Builder(activity);
final AlertDialog mReadMeDialog = mReadMeBuilder.create();
mReadMeDialog.show();
mReadMeDialog.setContentView(R.layout.read_me_layout);
mBackButton = (Button)mReadMeDialog.findViewById(R.id.back_buttonOnReadMe);
TextView mReadMeTextView = (TextView)mReadMeDialog.findViewById(R.id.ReadMeTextView);
if(Language==0){mReadMeTextView.setText(activity.getResources().getString(R.string.ReadMeGrDialog));}
else{mReadMeTextView.setText(activity.getResources().getString(R.string.ReadMeEngDialog));}
mBackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mReadMeDialog.cancel();
}
});
}
示例4: promptForMusicAccess
import android.app.AlertDialog; //导入方法依赖的package包/类
private void promptForMusicAccess() {
if (alreadyPrompted) return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!prefs.getString("headerStyle2", "Search Bar").equals("Music Controls") &&
!prefs.getString("city", "San Francisco").equals("Music:music-theme")) {
return;
}
alreadyPrompted = true;
AlertDialog.Builder d = new AlertDialog.Builder(MainActivity.this);
d.setTitle("Notification Access Required");
d.setMessage("SF Launcher requires access to notifications in order to display music info and album art. Please enable it on the next page.");
d.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
}
});
d.show();
}
示例5: onCreateDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setTitle(getPreference().getDialogTitle())
.setIcon(getPreference().getDialogIcon())
.setPositiveButton(getPreference().getPositiveButtonText(), this)
.setNegativeButton(getPreference().getNegativeButtonText(), this);
View contentView = onCreateDialogView(context);
if (contentView != null) {
onBindDialogView(contentView);
builder.setView(contentView);
} else {
builder.setMessage(getPreference().getDialogMessage());
}
this.dialog = builder.create();
return dialog;
}
示例6: onMarkerClick
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
CellTowerMarker cellTowerMarker = (CellTowerMarker) marker;
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(cellTowerMarker.getTitle());
dialog.setView(getInfoContents(cellTowerMarker.getMarkerData()));
dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
dialog.show();
return true;
}
示例7: showErrorAlert
import android.app.AlertDialog; //导入方法依赖的package包/类
private void showErrorAlert(String error) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
switch (error) {
case "USERNAME_INVALID":
builder.setMessage(LocaleController.getString("LinkInvalid", R.string.LinkInvalid));
break;
case "USERNAME_OCCUPIED":
builder.setMessage(LocaleController.getString("LinkInUse", R.string.LinkInUse));
break;
case "USERNAMES_UNAVAILABLE":
builder.setMessage(LocaleController.getString("FeatureUnavailable", R.string.FeatureUnavailable));
break;
default:
builder.setMessage(LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
break;
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(builder.create());
}
示例8: showAvisoDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
private void showAvisoDialog() {
AlertDialog.Builder alert = new AlertDialog.Builder(this, R.style.DialogTheme);
alert.setTitle("Aviso");
alert.setMessage("Estás a punto de agregar un producto que este centro de acopio" +
" necesita, por favor introduce solamente información verídica y confirmada");
alert.setPositiveButton("Aceptar", null);
alert.show();
}
示例9: isNewDayValid
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
*
* @return
*/
private boolean isNewDayValid() {
// check if the value in form is valid
String text = newClosingDay.getText().toString();
String alertMsg = "";
if (text!=null && text.length()>0) {
// Max day of reference month
Calendar periodCal = new GregorianCalendar(year, month, 1);
int maxDay = periodCal.getActualMaximum(Calendar.DAY_OF_MONTH);
int newCD = Integer.parseInt(text);
if (newCD<1 || newCD>maxDay) {
alertMsg = getString(R.string.alert_invalid_closing_day)+" [1-"+maxDay+"].";
} else if (newCD==regularClosingDay) {
alertMsg = getString(R.string.alert_regular_closing_day);
}
} else {
// text null - alert user
alertMsg = getString(R.string.alert_null_closing_day);
}
if (alertMsg.length()>0) {
// Alert message
Log.w("Alert", alertMsg);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage(alertMsg);
dlgAlert.setTitle(R.string.closing_day);
dlgAlert.setPositiveButton(R.string.ok, null);
dlgAlert.setCancelable(true);
dlgAlert.create().show();
return false;
} else {
return true;
}
}
示例10: dialogBuilder
import android.app.AlertDialog; //导入方法依赖的package包/类
public static AlertDialog.Builder dialogBuilder(Context context, String title, String msg) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
if (msg != null) {
builder.setMessage(msg);
}
if (title != null) {
builder.setTitle(title);
}
return builder;
}
示例11: showDialogFinish
import android.app.AlertDialog; //导入方法依赖的package包/类
public void showDialogFinish(final OrderDetail orderDetail){
final AlertDialog dialog_finish;
AlertDialog.Builder builder = new AlertDialog.Builder(context,R.style.DialogTransBackGround);
dialog_finish = builder.create();
dialog_finish.setCancelable(true);
dialog_finish.show();
View view_dialog = LayoutInflater.from(context).inflate(R.layout.item_dialog_confirm, null);
dialog_finish.setContentView(view_dialog);
TextView tv_title = (TextView) view_dialog.findViewById(R.id.tv_dialog_title);
TextView tv_content = (TextView) view_dialog.findViewById(R.id.tv_dialog_content);
Button bt_yes = (Button) view_dialog.findViewById(R.id.bt_dialog_yes);
tv_title.setText("提示");
tv_content.setText("确定要申请退货吗?");
bt_yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog_finish.dismiss();
if (orderDetail.state == 4) {
if (orderDetail.orderDetailId == 0) {
Toast.makeText(context, "orderDetailId为空!", Toast.LENGTH_SHORT).show();
} else {
orderDetail.state = 5;
orderDetail.refundStatus = 1;
notifyDataSetChanged();
MyOrderActivity.instance.refundOrder(orderId, orderDetail.orderDetailId);
}
}
}
});
}
示例12: onCreateDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* Applies the args
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.DialogStyle);
// Apply args
builder.setTitle(title).setSingleChoiceItems(choices, active, onC).setPositiveButton("OK", onC);
Dialog d = builder.create();
d.setCanceledOnTouchOutside(false);
// Create the AlertDialog object and return it
return d;
}
示例13: init
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* Attempts to create the scanner.
*
* @param context
* @return true if successful
*/
public boolean init(final Activity context) {
// New Android M+ permission check requirement.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (context.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("This app needs coarse location access");
builder.setMessage("Please grant coarse location access so this app can scan for beacons");
builder.setPositiveButton(android.R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
PERMISSION_REQUEST_COARSE_LOCATION);
}
});
builder.show();
}
}
BluetoothManager manager = (BluetoothManager) context.getApplicationContext()
.getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter btAdapter = manager.getAdapter();
if (btAdapter == null) {
return false;
} else if (!btAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
context.startActivityForResult(enableBtIntent, mRequestEnableBluetooth);
return false;
} else {
scanner = btAdapter.getBluetoothLeScanner();
}
return true;
}
示例14: menu
import android.app.AlertDialog; //导入方法依赖的package包/类
void menu() {
//Log.v(APP_TAG, "Trying to open menu");
if (lock) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
//builder.setTitle("");
builder.setMessage(getResources().getString(R.string.type_password));
final EditText inputBox = new EditText(this);
inputBox.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD);
builder.setView(inputBox);
builder.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (inputBox.getText().toString().equals(options.getString(Keys.PASSWORD, ""))) {
openOptionsMenu();
} else {
Toast.makeText(getApplicationContext(), getResources().getString(R.string.wrong_password), Toast.LENGTH_LONG).show();
}
} });
builder.setCancelable(true);
if (!isFinishing()) {
builder.show();
}
} else {
openOptionsMenu();
}
}
示例15: onImageLongClickExtraUrl
import android.app.AlertDialog; //导入方法依赖的package包/类
private void onImageLongClickExtraUrl(final String newUrl) {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
newTab(newUrl, true);
break;
case DialogInterface.BUTTON_NEGATIVE:
getCurrentWebView().loadUrl(newUrl);
break;
case DialogInterface.BUTTON_NEUTRAL:
if (API > 8) {
Utils.downloadFile(mActivity, newUrl,
getCurrentWebView().getUserAgent(), "attachment", false);
}
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
builder.setTitle(newUrl.replace(Constants.HTTP, ""))
.setMessage(getResources().getString(R.string.dialog_image))
.setPositiveButton(getResources().getString(R.string.action_new_tab),
dialogClickListener)
.setNegativeButton(getResources().getString(R.string.action_open),
dialogClickListener)
.setNeutralButton(getResources().getString(R.string.action_download),
dialogClickListener).show();
}