Java 类android.app.AlertDialog 实例源码
项目:JavaIsFun
文件:OQueEJava6.java
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();
}
项目:LaunchTime
文件:BackupActivity.java
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();
}
项目:Android-Code-Demos
文件:CameraBridgeViewBase.java
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();
}
}
项目:siteswap_generator
文件:MainActivity.java
@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);
}
项目:GracefulMovies
文件:CheckPermissionsActivity.java
/**
* 显示提示信息
*/
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();
}
项目:DaiGo
文件:ComplainActivity.java
@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;
}
}
项目:xmrwallet
文件:WalletActivity.java
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();
}
项目:AndroidCameraSudokuSolver
文件:CameraBridgeViewBase.java
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();
}
}
项目:RNLearn_Project1
文件:DialogModuleTest.java
@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());
}
项目:FaceDetectDemo
文件:CameraBridgeViewBase.java
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();
}
}
项目:SimpleUILauncher
文件:Launcher.java
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;
}
项目:ADBToolKitsInstaller
文件:MainActivity.java
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();
}
项目:Telephoto
文件:BuyActivity.java
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();
}
});
}
项目:Musicoco
文件:SplashActivity.java
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();
}
项目:EggRating
文件:EggRating.java
/**
* 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();
}
项目:Obd2-Tracker
文件:ChooseBtDeviceDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
final List<BluetoothDevice> bondedDevices = new ArrayList<>(btAdapter.getBondedDevices());
String[] boundedDeviceNames = new String[bondedDevices.size()];
for (int i = 0; i < bondedDevices.size(); i++) {
boundedDeviceNames[i] = bondedDevices.get(i).getName();
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.choose_bt_device)
.setCancelable(false)
.setItems(boundedDeviceNames, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
BluetoothDevice bluetoothDevice = bondedDevices.get(which);
listener.onDeviceChoose(bluetoothDevice);
}
});
return builder.create();
}
项目:LaunchEnr
文件:ThemePreference.java
private void showDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
final ThemeAdapter adapter = new ThemeAdapter(mContext, themeValues, themeOptions, getPersistedString("0"));
builder.setTitle(R.string.pref_theme_title);
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
String item = adapter.getItem(position);
persistString(item);
}
});
builder.show();
}
项目:UbiBike-client
文件:Station.java
private void dialogBookBike(String stationName) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
builder1.setMessage("Booking successful in " + stationName + ". Choose your bike!");
builder1.setCancelable(true);
builder1.setPositiveButton(
"Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
globalVariable.setBooking(true);
dialog.cancel();
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
}
项目:aDictOnCopy
文件:DictionaryChooser.java
public void prompt(final OnSelectedListener listener) {
AlertDialog.Builder builder = new AlertDialog.Builder(mCtx);
builder.setTitle(R.string.prompt_select_dict_title);
final List<DictionaryManager.DictChoiceItem> choices = mDictMgr.getAvailableDictionaries();
builder.setAdapter(new DictChoicesAdapter(choices), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
PLog.v("DictionaryChooser.prompt(): <%s> is selected.", choices.get(which).getPackageName());
listener.onSelected(choices.get(which));
}
});
builder.create().show();
}
项目:XERUNG
文件:GroupSettings.java
private void selectImage() {
final CharSequence[] items = { "Take Photo", "Choose from Gallery","Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(GroupSettings.this);
builder.setTitle("Select Photo");
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (items[item].equals("Take Photo")) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent,REQUEST_IMAGE_CAPTURE);
}
} else if (items[item].equals("Choose from Gallery")) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
} else if (items[item].equals("Cancel")) {
dialog.dismiss();
}
}
});
builder.show();
}
项目:GCSApp
文件:ChatRoomDetailsActivity.java
private void showAnnouncementDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.group_announcement);
if (room.getOwner().equals(EMClient.getInstance().getCurrentUser()) ||
room.getAdminList().contains(EMClient.getInstance().getCurrentUser())) {
final EditText et = new EditText(ChatRoomDetailsActivity.this);
et.setText(room.getAnnouncement());
builder.setView(et);
builder.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String text = et.getText().toString();
if (!text.equals(room.getAnnouncement())) {
dialog.dismiss();
updateAnnouncement(text);
}
}
});
} else {
builder.setMessage(room.getAnnouncement());
builder.setPositiveButton(R.string.ok, null);
}
builder.show();
}
项目:PlusGram
文件:MessagesController.java
public static boolean isFeatureEnabled(String feature, BaseFragment fragment) {
if (feature == null || feature.length() == 0 || getInstance().disabledFeatures.isEmpty() || fragment == null) {
return true;
}
for (TLRPC.TL_disabledFeature disabledFeature : getInstance().disabledFeatures) {
if (disabledFeature.feature.equals(feature)) {
if (fragment.getParentActivity() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity());
builder.setTitle("Oops!");
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setMessage(disabledFeature.description);
fragment.showDialog(builder.create());
}
return false;
}
}
return true;
}
项目:LibVNCAndroid
文件:CanvasActivity.java
/**
* @brief Show the dialog with the exit question
* @return The new dialog
* @details Show the dialog with the exit question
*/
private Dialog exitDialog() {
final String titleExit = getString(R.string.DialogTitleExit);
final String question = getString(R.string.DialogQuestion);
return new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(titleExit)
.setMessage(question)
.setNegativeButton(android.R.string.cancel, null)//sin listener
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){
vnc.finishVnc();
finishConnection();
}
})
.show();
}
项目:FCM-for-Mojo
文件:MainActivity.java
@Override
public boolean onOptionsItemSelected(int itemId) {
switch (itemId) {
case R.id.action_about:
Dialog dialog = new AlertDialog.Builder(this)
.setView(R.layout.dialog_about)
.show();
((TextView) dialog.findViewById(R.id.icon_credits)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView) dialog.findViewById(R.id.icon_credits)).setText(Html.fromHtml(getString(R.string.about_icon_credits), Html.FROM_HTML_MODE_COMPACT));
return true;
case R.id.action_donate:
onDonateSelected();
return true;
}
return super.onOptionsItemSelected(itemId);
}
项目:buildAPKsApps
文件:GameMasterDice.java
void configureDice(DiceSet defaults, final OnDiceChange onOk) {
android.view.LayoutInflater inflater = (android.view.LayoutInflater)getSystemService(
LAYOUT_INFLATER_SERVICE);
View group = inflater.inflate(R.layout.dg_configure, null, false);
final NumberPicker np_c = setupNumPicker(group, R.id.spin_count, defaults.count);
final Spinner sp_s = setupSpinner(group, R.id.spin_sides, SPIN_SIDES, defaults.sides);
final NumberPicker np_m = setupNumPicker(group, R.id.spin_modifier, defaults.modifier);
new AlertDialog.Builder(this)
.setTitle(R.string.ds_config)
.setView(group)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
DiceSet ds = DiceSet.getDiceSet(np_c.getCurrent(),
(Integer)sp_s.getSelectedItem(),
(Integer)np_m.getCurrent());
onOk.onDiceChange(ds);
}
})
.setNegativeButton(android.R.string.cancel, null)
.create().show();
}
项目:Tasks
文件:CalenderFragment.java
private void showDeleteAllDialog(Task task) {
AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setTitle("Delete All")
.setMessage("Delete All Occurrence of this Task?")
.setPositiveButton("No", (dialogInterface, i) -> {
dialogInterface.dismiss();
presenter.deleteTask(task, false);
updateAfterDelete(task);
})
.setNegativeButton("Yes", (dialogInterface, i) -> {
dialogInterface.dismiss();
presenter.deleteTask(task, true);
updateAfterDelete(task);
})
.create();
dialog.show();
}
项目:MOAAP
文件:CameraBridgeViewBase.java
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();
}
}
项目:PokerBankroll
文件:Funcoes.java
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();
}
项目:AppRTC-Android
文件:ConnectActivity.java
private boolean validateUrl(String url) {
if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) {
return true;
}
new AlertDialog.Builder(this)
.setTitle(getText(R.string.invalid_url_title))
.setMessage(getString(R.string.invalid_url_text, url))
.setCancelable(false)
.setNeutralButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.create()
.show();
return false;
}
项目:aos-Video
文件:MoviesByFragment.java
private void setupEventListeners() {
setOnSearchClickedListener(new View.OnClickListener() {
public void onClick(View view) {
mSortOrderItem = sortOrder2Item(mSortOrder);
new AlertDialog.Builder(getActivity())
.setSingleChoiceItems(getSortOrderEntries(), mSortOrderItem, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (mSortOrderItem != which) {
mSortOrderItem = which;
mSortOrder = item2SortOrder(mSortOrderItem);
loadCategoriesRows(mCurrentCategoriesCursor);
}
dialog.dismiss();
}
})
.create().show();
}
});
setOnItemViewClickedListener(new VideoViewClickedListener(getActivity()));
}
项目:grafika
文件:AboutBox.java
/**
* Displays the About box. An AlertDialog is created in the calling activity's context.
* <p>
* The box will disappear if the "OK" button is touched, if an area outside the box is
* touched, if the screen is rotated ... doing just about anything makes it disappear.
*/
public static void display(Activity caller) {
String versionStr = getVersionString(caller);
String aboutHeader = caller.getString(R.string.app_name) + " v" + versionStr;
// Manually inflate the view that will form the body of the dialog.
View aboutView;
try {
aboutView = caller.getLayoutInflater().inflate(R.layout.about_dialog, null);
} catch (InflateException ie) {
Log.e(TAG, "Exception while inflating about box: " + ie.getMessage());
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(caller);
builder.setTitle(aboutHeader);
builder.setIcon(R.drawable.ic_launcher);
builder.setCancelable(true); // implies setCanceledOnTouchOutside
builder.setPositiveButton(R.string.ok, null);
builder.setView(aboutView);
builder.show();
}
项目:ProjectLumen
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Boolean isFlashAvailable = getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
if (!isFlashAvailable) {
AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create();
alert.setTitle(getString(R.string.app_name));
alert.setMessage("Error");
alert.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alert.show();
}
Intent i = new Intent(this, BackgroundService.class);
startService(i);
Log.d("ProjectLumen","loaded");
}
项目:editor
文件:Editor.java
private void aboutClicked()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.about);
DateFormat dateFormat = DateFormat.getDateTimeInstance();
String format = getString(R.string.version);
String message =
String.format(Locale.getDefault(),
format, BuildConfig.VERSION_NAME,
dateFormat.format(BuildConfig.BUILT));
builder.setMessage(message);
// Add the button
builder.setPositiveButton(R.string.ok, null);
// Create the AlertDialog
Dialog dialog = builder.show();
// Set movement method
TextView text = (TextView) dialog.findViewById(android.R.id.message);
if (text != null)
text.setMovementMethod(LinkMovementMethod.getInstance());
}
项目:Tensorflow_Andriod_With_Audio_Output
文件:CameraConnectionFragment.java
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Activity activity = getActivity();
return new AlertDialog.Builder(activity)
.setMessage(getArguments().getString(ARG_MESSAGE))
.setPositiveButton(
android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialogInterface, final int i) {
activity.finish();
}
})
.create();
}
项目:COB
文件:Notification.java
@SuppressLint("NewApi")
private void changeTextDirection(Builder dlg){
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
dlg.create();
AlertDialog dialog = dlg.show();
if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
TextView messageview = (TextView)dialog.findViewById(android.R.id.message);
messageview.setTextDirection(android.view.View.TEXT_DIRECTION_LOCALE);
}
}
项目:TripBuyer
文件:MMAlert.java
public static AlertDialog showAlert(final Context context, final int msg, final int title, final int yes, final int no, final DialogInterface.OnClickListener lOk,
final DialogInterface.OnClickListener lCancel) {
if (context instanceof Activity && ((Activity) context).isFinishing()) {
return null;
}
final Builder builder = new AlertDialog.Builder(context);
builder.setIcon(R.drawable.ic_dialog_alert);
builder.setTitle(title);
builder.setMessage(msg);
builder.setPositiveButton(yes, lOk);
builder.setNegativeButton(no, lCancel);
// builder.setCancelable(false);
final AlertDialog alert = builder.create();
alert.show();
return alert;
}
项目:mininoteview
文件:MainActivity.java
private void showDialog(String msg)
{
new AlertDialog.Builder(this)
.setMessage(msg)
.setNeutralButton(R.string.action_ok, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
}
})
.show();
}
项目:Chidori
文件:ErrorDialogFragments.java
public static Dialog createDialog(Context context, Bundle arguments, OnClickListener onClickListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(arguments.getString(ErrorDialogManager.KEY_TITLE));
builder.setMessage(arguments.getString(ErrorDialogManager.KEY_MESSAGE));
if (ERROR_DIALOG_ICON != 0) {
builder.setIcon(ERROR_DIALOG_ICON);
}
builder.setPositiveButton(android.R.string.ok, onClickListener);
return builder.create();
}
项目:UIWidget
文件:UIAlertView.java
public UIAlertView(Context context) {
this.context = context;
// 获取Dialog布局
View view = LayoutInflater.from(context).inflate(
R.layout.layout_alert_view, null);
// 获取自定义Dialog布局中的控件
imageViewDelete = (ImageView) view.findViewById(R.id.iv_deleteAlertView);
imageViewDelete.setVisibility(View.GONE);
mTvTitle = (TextView) view.findViewById(R.id.tv_titleAlertView);
mTvTitle.setVisibility(View.GONE);
mTvMsg = (TextView) view.findViewById(R.id.tv_msgAlertView);
mTvMsg.setVisibility(View.GONE);
dialog_Group = (LinearLayout) view.findViewById(R.id.lLayout_viewAlertView);
btn_left = (TextView) view.findViewById(R.id.tv_leftAlertView);
btn_left.setVisibility(View.GONE);
btn_middle = (TextView) view.findViewById(R.id.tv_middleAlertView);
btn_middle.setVisibility(View.GONE);
btn_right = (TextView) view.findViewById(R.id.tv_rightAlertView);
btn_right.setVisibility(View.GONE);
mViewLine = view.findViewById(R.id.v_lineAlertView);
mViewLine.setVisibility(View.GONE);
mViewLineHorizontal = view.findViewById(R.id.v_lineHorizontalAlertView);
mViewLineHorizontal.setVisibility(View.GONE);
mViewLineRight = view.findViewById(R.id.v_lineRightAlertView);
mViewLineRight.setVisibility(View.GONE);
linearLayoutGroup = (LinearLayout) view.findViewById(R.id.lLayout_groupAlertView);
linearLayoutMain = (LinearLayout) view.findViewById(R.id.lLayout_mainAlertView);
// 定义Dialog布局和参数
dialog = new AlertDialog.Builder(context, R.style.AlertViewDialogStyle).create();
dialog.show();
dialog.setContentView(view);
window = dialog.getWindow();
lp = window.getAttributes();
window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
dialog.dismiss();
}
项目:BeaconMqtt
文件:NewBeaconActivity.java
@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();
//noinspection SimplifiableIfStatement
if (id == R.id.menu_add_beacon_manually) {
AlertDialog.Builder builder = createAlertDialog();
builder.show();
}
return super.onOptionsItemSelected(item);
}