当前位置: 首页>>代码示例>>Java>>正文


Java AlertDialog类代码示例

本文整理汇总了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();
}
 
开发者ID:jvbeltra,项目名称:JavaIsFun,代码行数:18,代码来源:OQueEJava6.java

示例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();
    }
 
开发者ID:marcelohanel,项目名称:PokerBankroll,代码行数:20,代码来源:Funcoes.java

示例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();
    }
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:21,代码来源:BackupActivity.java

示例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();

    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:18,代码来源:CameraBridgeViewBase.java

示例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);
}
 
开发者ID:namlit,项目名称:siteswap_generator,代码行数:21,代码来源:MainActivity.java

示例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();
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:20,代码来源:CheckPermissionsActivity.java

示例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;
    }
}
 
开发者ID:838030195,项目名称:DaiGo,代码行数:22,代码来源:ComplainActivity.java

示例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();
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:24,代码来源:WalletActivity.java

示例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();

    }
}
 
开发者ID:jocstech,项目名称:AndroidCameraSudokuSolver,代码行数:17,代码来源:CameraBridgeViewBase.java

示例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());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:DialogModuleTest.java

示例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;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:17,代码来源:Launcher.java

示例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();
}
 
开发者ID:Crixec,项目名称:ADBToolKitsInstaller,代码行数:20,代码来源:MainActivity.java

示例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();
        }
    });
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:21,代码来源:BuyActivity.java

示例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();
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:25,代码来源:SplashActivity.java

示例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();

}
 
开发者ID:ppyzza,项目名称:EggRating,代码行数:22,代码来源:EggRating.java


注:本文中的android.app.AlertDialog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。