本文整理汇总了Java中android.app.AlertDialog类的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog类的具体用法?Java AlertDialog怎么用?Java AlertDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlertDialog类属于android.app包,在下文中一共展示了AlertDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: imageDialog2
import android.app.AlertDialog; //导入依赖的package包/类
public void imageDialog2(View view){
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this);
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.step2);
builder.setTitle("Clique em 'Novo projeto'...")
.setView(imageView)
.setNegativeButton("Voltar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
})
.show();
}
示例2: showMessage
import android.app.AlertDialog; //导入依赖的package包/类
public static void showMessage(Context context, String title, String message, String textButton) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage(message);
builder.setCancelable(false);
builder.setPositiveButton(textButton,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}
);
builder.create();
builder.show();
}
示例3: promptResetDb
import android.app.AlertDialog; //导入依赖的package包/类
private void promptResetDb() {
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.reset_db)
.setMessage(R.string.reset_db_explain)
.setPositiveButton(R.string.reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
db().backup("Before reset");
db().deleteDatabase();
String message = getString(R.string.restore_successful);
restartApp();
Toast.makeText(BackupActivity.this, message, Toast.LENGTH_LONG).show();
}
}).setNegativeButton(R.string.cancel, null);
builder.show();
}
示例4: onEnterStartedState
import android.app.AlertDialog; //导入依赖的package包/类
private void onEnterStartedState() {
Log.d(TAG, "call onEnterStartedState");
/* Connect camera */
if (!connectCamera(getWidth(), getHeight())) {
AlertDialog ad = new AlertDialog.Builder(getContext()).create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
((Activity) getContext()).finish();
}
});
ad.show();
}
}
示例5: onOptionsItemSelected
import android.app.AlertDialog; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_about)
{
showAboutDialog();
}
else if (id == R.id.action_help) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(Html.fromHtml(getString(R.string.help_activity__help_html_text)))
.setNeutralButton(getString(R.string.back), null);
builder.create().show();
}
return super.onOptionsItemSelected(item);
}
示例6: showMissingPermissionDialog
import android.app.AlertDialog; //导入依赖的package包/类
/**
* 显示提示信息
*/
private void showMissingPermissionDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.permission_title);
builder.setMessage(R.string.permission_msg);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.settings,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startAppSettings();
}
});
builder.setCancelable(false);
builder.show();
}
示例7: handleMessage
import android.app.AlertDialog; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
final ComplainActivity activity = activityWeakReference.get();
activity.stopProgressDialog();
switch (msg.what) {
case 0:
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage("投诉已提交。我们将会尽快处理您的投诉。");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
activity.finish();
}
});
builder.show();
break;
case 1:
Toast.makeText(activity, "网络错误", Toast.LENGTH_SHORT).show();
break;
}
}
示例8: onWalletDetails
import android.app.AlertDialog; //导入依赖的package包/类
private void onWalletDetails() {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
Bundle extras = new Bundle();
extras.putString("type", GenerateReviewFragment.VIEW_TYPE_WALLET);
replaceFragment(new GenerateReviewFragment(), null, extras);
break;
case DialogInterface.BUTTON_NEGATIVE:
// do nothing
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.details_alert_message))
.setPositiveButton(getString(R.string.details_alert_yes), dialogClickListener)
.setNegativeButton(getString(R.string.details_alert_no), dialogClickListener)
.show();
}
示例9: onEnterStartedState
import android.app.AlertDialog; //导入依赖的package包/类
private void onEnterStartedState() {
/* Connect camera */
if (!connectCamera(getWidth(), getHeight())) {
AlertDialog ad = new AlertDialog.Builder(getContext()).create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
((Activity) getContext()).finish();
}
});
ad.show();
}
}
示例10: testAllOptions
import android.app.AlertDialog; //导入依赖的package包/类
@Test
public void testAllOptions() {
final JavaOnlyMap options = new JavaOnlyMap();
options.putString("title", "Title");
options.putString("message", "Message");
options.putString("buttonPositive", "OK");
options.putString("buttonNegative", "Cancel");
options.putString("buttonNeutral", "Later");
options.putBoolean("cancelable", false);
mDialogModule.showAlert(options, null, null);
final AlertFragment fragment = getFragment();
assertNotNull("Fragment was not displayed", fragment);
assertEquals(false, fragment.isCancelable());
final AlertDialog dialog = (AlertDialog) fragment.getDialog();
assertEquals("OK", dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText().toString());
assertEquals("Cancel", dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText().toString());
assertEquals("Later", dialog.getButton(DialogInterface.BUTTON_NEUTRAL).getText().toString());
}
示例11: showBrokenAppInstallDialog
import android.app.AlertDialog; //导入依赖的package包/类
private void showBrokenAppInstallDialog(final String packageName,
DialogInterface.OnClickListener onSearchClickListener) {
new AlertDialog.Builder(this)
.setTitle(R.string.abandoned_promises_title)
.setMessage(R.string.abandoned_promise_explanation)
.setPositiveButton(R.string.abandoned_search, onSearchClickListener)
.setNeutralButton(R.string.abandoned_clean_this,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final UserHandleCompat user = UserHandleCompat.myUserHandle();
mWorkspace.removeAbandonedPromise(packageName, user);
}
})
.create().show();
return;
}
示例12: runCommands
import android.app.AlertDialog; //导入依赖的package包/类
public void runCommands() {
final View dialogView = getLayoutInflater().inflate(R.layout.layout_input, null, false);
final EditText editText = (EditText) dialogView.findViewById(R.id.editText);
final CheckBox checkBox = (CheckBox) dialogView.findViewById(R.id.checkbox);
new AlertDialog.Builder(this).setTitle(R.string.run_commands)
.setView(dialogView)
.setCancelable(false)
.setNeutralButton(android.R.string.cancel, null).setPositiveButton(R.string.run, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
List<String> commands = new ArrayList<>();
commands.add("alias adb=\'" + getApplicationInfo().nativeLibraryDir + "/libadb.so\'");
commands.add("alias fastboot=\'" + getApplicationInfo().nativeLibraryDir + "/libfastboot.so\'");
commands.add(editText.getText().toString());
new RunCommandsTask(dialogView.getContext(), commands, getString(R.string.running), checkBox.isChecked()).execute();
}
})
.show();
}
示例13: afterPayment
import android.app.AlertDialog; //导入依赖的package包/类
private void afterPayment() {
PrefsController.instance.makePro();
Answers.getInstance().logCustom(new CustomEvent(ANSWER_STEP_BUY).putCustomAttribute("step", "Go Pro!"));
runOnUiThread(new Runnable() {
@Override
public void run() {
new AlertDialog.Builder(BuyActivity.this)
.setTitle(R.string.warning)
.setMessage(R.string.buy_thank_you_for_bought)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
BuyActivity.this.finish();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
});
}
示例14: handleEmptyLibrary
import android.app.AlertDialog; //导入依赖的package包/类
private void handleEmptyLibrary() {
container.setClickable(true);
container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (TextView t : ts) {
startTextInAnim(t);
}
int color = ColorUtils.getRandomBrunetColor();
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TL_BR,
new int[]{
android.support.v4.graphics.ColorUtils.setAlphaComponent(color, 100),
color,
});
v.setBackground(gd);
}
});
DialogProvider p = new DialogProvider(this);
AlertDialog dialog = p.createInfosDialog(getString(R.string.tip), getString(R.string.info_empty_library_when_start));
dialog.setCancelable(true);
dialog.show();
}
示例15: showAlertThanks
import android.app.AlertDialog; //导入依赖的package包/类
/**
* an Method check condition before show dialog.
*/
private void showAlertThanks(final OnSelectCallBack mOnSelectCallBack) {
int titleId = mConfiguration.mTitleThanksId != 0 ? mConfiguration.mTitleThanksId : R.string.rateus_text_thanks_title;
int messageId = mConfiguration.mTitleThanksDescId != 0 ? mConfiguration.mTitleThanksDescId : R.string.rateus_text_thanks_description;
int okId = mConfiguration.mYesButtonId != 0 ? mConfiguration.mYesButtonId : R.string.rateus_text_thanks_ok;
final AlertDialog.Builder mAlert = new AlertDialog.Builder(mActivity);
mAlert.setCancelable(true);
mAlert.setTitle(titleId);
mAlert.setMessage(messageId);
mAlert.setPositiveButton(okId, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
mOnSelectCallBack.onPositive(EGGRATING_THANKS_DIALOG);
}
});
mAlert.show();
}