Java Code Examples for androidx.appcompat.app.AlertDialog#setTitle()
The following examples show how to use
androidx.appcompat.app.AlertDialog#setTitle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoodleDrawActivity.java From djl-demo with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(Boolean result) { if (result) { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); paintView.init(metrics, imageView, textView, predictor); progressBar.setVisibility(View.GONE); containerView.setVisibility(View.VISIBLE); } else { AlertDialog alertDialog = new AlertDialog.Builder(DoodleDrawActivity.this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Failed to load model"); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", (dialog, which) -> finish()); } }
Example 2
Source File: MainActivity.java From cythara with GNU General Public License v3.0 | 6 votes |
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == RECORD_AUDIO_PERMISSION) { if (grantResults.length > 0) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { startRecording(); } else { AlertDialog alertDialog = new Builder(MainActivity.this).create(); alertDialog.setTitle(R.string.permission_required); alertDialog.setMessage(getString(R.string.microphone_permission_required)); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok), (dialog, which) -> { dialog.dismiss(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { finishAffinity(); } else { finish(); } }); alertDialog.show(); } } } }
Example 3
Source File: SortFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
public void onItemDismiss(final int position) { final Times times = Times.getTimesAt(position); AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle(R.string.delete); dialog.setMessage(getString(R.string.delCityConfirm, times.getName())); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), (dialogInterface, i) -> { times.delete(); mAdapter.notifyItemRemoved(position); }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), (dialogInterface, i) -> { dialogInterface.cancel(); mAdapter.notifyDataSetChanged(); }); dialog.show(); }
Example 4
Source File: PrivateActivity.java From SimplicityBrowser with MIT License | 6 votes |
private void createFileName() { LayoutInflater inflater = getLayoutInflater(); Bitmap resizedBitmap = Bitmap.createBitmap(favoriteIcon); @SuppressLint("InflateParams") View alertLayout = inflater.inflate(R.layout.layout_shortcut, null); shortcutNameEditText = alertLayout.findViewById(R.id.shortcut_name_edittext); AlertDialog alertDialog = createExitDialog(); alertDialog.setTitle(R.string.add_home); alertDialog.setView(alertLayout); alertDialog.show(); shortcutNameEditText.setHint(webViewTitle); ImageView imageShortcut = alertDialog.findViewById(R.id.fav_imageView); if (imageShortcut != null) { imageShortcut.setImageBitmap(StaticUtils.getCircleBitmap(resizedBitmap)); }else{ Log.d("Null", ""); } alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(this, R.color.md_blue_600)); alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(Color.LTGRAY); }
Example 5
Source File: MainActivity.java From SimplicityBrowser with MIT License | 6 votes |
private void createFileName() { LayoutInflater inflater = getLayoutInflater(); Bitmap resizedBitmap = Bitmap.createBitmap(favoriteIcon); @SuppressLint("InflateParams") View alertLayout = inflater.inflate(R.layout.layout_shortcut, null); shortcutNameEditText = alertLayout.findViewById(R.id.shortcut_name_edittext); AlertDialog alertDialog = createExitDialog(); alertDialog.setTitle(R.string.add_home); alertDialog.setView(alertLayout); alertDialog.show(); shortcutNameEditText.setHint(webViewTitle); ImageView imageShortcut = alertDialog.findViewById(R.id.fav_imageView); if (imageShortcut != null) { imageShortcut.setImageBitmap(StaticUtils.getCircleBitmap(resizedBitmap)); }else{ Log.d("Null", ""); } alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(this, R.color.md_blue_600)); alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(this, R.color.md_blue_600)); }
Example 6
Source File: MenuHelper.java From webTube with GNU General Public License v3.0 | 6 votes |
public void homepageTutorial() { if (!sp.getBoolean("homepageLearned", false)) { AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setTitle(context.getString(R.string.home)); dialog.setMessage(context.getString(R.string.homePageHelp)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", (dialog1, buttonId) -> { dialog1.dismiss(); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean("homepageLearned", true); editor.apply(); }); dialog.show(); } }
Example 7
Source File: SortFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
public void onItemDismiss(final int position) { final Times times = Times.getTimesAt(position); AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle(R.string.delete); dialog.setMessage(getString(R.string.delCityConfirm, times.getName())); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), (dialogInterface, i) -> { times.delete(); mAdapter.notifyItemRemoved(position); }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), (dialogInterface, i) -> { dialogInterface.cancel(); mAdapter.notifyDataSetChanged(); }); dialog.show(); }
Example 8
Source File: MenuHelper.java From webTube with GNU General Public License v3.0 | 6 votes |
public void homepageTutorial() { if (!sp.getBoolean("homepageLearned", false)) { AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setTitle(context.getString(R.string.home)); dialog.setMessage(context.getString(R.string.homePageHelp)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", (dialog1, buttonId) -> { dialog1.dismiss(); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean("homepageLearned", true); editor.apply(); }); dialog.show(); } }
Example 9
Source File: DhikrFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
private void deleteDhikr() { AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle(R.string.delete); dialog.setMessage(getString(R.string.delConfirmDhikr, mDhikrs.get(0).getTitle())); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), (dialogInterface, i) -> mViewModel.deleteDhikr(mDhikrs.get(0))); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), (dialogInterface, i) -> { }); dialog.show(); }
Example 10
Source File: MenuHelper.java From webTube with GNU General Public License v3.0 | 5 votes |
private void show_noVideo_dialog() { AlertDialog dialog = new AlertDialog.Builder(context/**/).create(); dialog.setTitle(context.getString(R.string.error_no_video)); dialog.setMessage(context.getString(R.string.error_select_video_and_retry)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok).toUpperCase(), (dialog1, buttonId) -> dialog1.dismiss()); dialog.show(); }
Example 11
Source File: DhikrFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
private void deleteDhikr() { AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle(R.string.delete); dialog.setMessage(getString(R.string.delConfirmDhikr, mDhikrs.get(0).getTitle())); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), (dialogInterface, i) -> mViewModel.deleteDhikr(mDhikrs.get(0))); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), (dialogInterface, i) -> { }); dialog.show(); }
Example 12
Source File: MenuHelper.java From webTube with GNU General Public License v3.0 | 5 votes |
private void show_noVideo_dialog() { AlertDialog dialog = new AlertDialog.Builder(context/**/).create(); dialog.setTitle(context.getString(R.string.error_no_video)); dialog.setMessage(context.getString(R.string.error_select_video_and_retry)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok).toUpperCase(), (dialog1, buttonId) -> dialog1.dismiss()); dialog.show(); }
Example 13
Source File: AlertDialogFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Bundle args = getArguments(); final int titleResId = args.getInt(ARG_TITLE_RES); final int messageResId = args.getInt(ARG_MESSAGE_RES); final CharSequence title = titleResId != 0 ? getText(titleResId) : args.getString(ARG_TITLE); final CharSequence message = messageResId != 0 ? getText(messageResId) : args.getString(ARG_MESSAGE); final AlertDialog alertDialog = new AlertDialog.Builder(getContext()) .setMessage(message) .create(); alertDialog.setCanceledOnTouchOutside(false); if (title != null) { alertDialog.setTitle(title); } if (positiveButtonAttr != null) { alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, positiveButtonAttr.getText(), positiveButtonAttr.getOnClickListener()); } if (negativeButtonAttr != null) { alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, negativeButtonAttr.getText(), negativeButtonAttr.getOnClickListener()); } return alertDialog; }
Example 14
Source File: MainActivity.java From YouTube-In-Background with MIT License | 4 votes |
/** * Handles selected item from action bar * * @param item the selected item from the action bar * @return boolean */ @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(); Locale locale = getResources().getConfiguration().locale; //noinspection SimplifiableIfStatement switch (id) { case R.id.action_about: DateFormat monthFormat = new SimpleDateFormat("MMMM", locale); DateFormat yearFormat = new SimpleDateFormat("yyyy", locale); Date date = new Date(); AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle("Teocci"); alertDialog.setIcon(R.mipmap.ic_launcher); alertDialog.setMessage( "Dedicated to the person who gives me a reason to smile even on the dullest of days." + ".\n" + "누리 고마워~ Thanks for been in my life." + "\n\n" + "YiB v" + BuildConfig.VERSION_NAME + "\n\[email protected]\n\n" + monthFormat.format(date) + " " + yearFormat.format(date) + ".\n" ); alertDialog.setButton( AlertDialog.BUTTON_NEUTRAL, "OK", (dialog, which) -> dialog.dismiss() ); alertDialog.show(); return true; case R.id.action_clear_list: YouTubeSqlDb.getInstance() .videos(YouTubeSqlDb.VIDEOS_TYPE.RECENTLY_WATCHED) .deleteAll(); recentlyPlayedFragment.clearRecentlyPlayedList(); return true; case R.id.action_remove_account: SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String chosenAccountName = sp.getString(ACCOUNT_NAME, null); if (chosenAccountName != null) { sp.edit().remove(ACCOUNT_NAME).apply(); } return true; case R.id.action_search: item.expandActionView(); return true; } return super.onOptionsItemSelected(item); }
Example 15
Source File: MainActivity.java From prayer-times-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String lang = LocaleUtils.getLanguage("en", "de", "tr"); final String file = lang + "/hadis.db"; final String url = App.API_URL + "/files/hadis." + lang + ".db"; File f = new File(App.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), file); if (f.exists()) { try { if (SqliteHelper.get().getCount() == 0) { SqliteHelper.get().close(); ((Object) null).toString(); } } catch (Exception e) { if (f.exists() && !f.delete()) { Log.e("BaseActivity", "could not delete " + f.getAbsolutePath()); } finish(); } setDefaultFragment(new HadithFragment()); moveToFrag(getDefaultFragment()); } else if (!App.isOnline()) { Toast.makeText(this, R.string.no_internet, Toast.LENGTH_SHORT).show(); } else { AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle(R.string.hadith); dialog.setMessage(getString(R.string.dlHadith)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), (dialogInterface, i) -> { File f1 = new File(App.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), file); if (!f1.getParentFile().mkdirs()) { Log.e("BaseActivity", "could not mkdirs " + f1.getParent()); } final ProgressDialog dlg = new ProgressDialog(MainActivity.this); dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dlg.setCancelable(false); dlg.setCanceledOnTouchOutside(false); dlg.show(); Ion.with(MainActivity.this).load(url).progressDialog(dlg).write(f1).setCallback((e, result) -> { dlg.dismiss(); if (e != null) { e.printStackTrace(); Crashlytics.logException(e); Toast.makeText(MainActivity.this, R.string.error, Toast.LENGTH_LONG).show(); finish(); } else if (result.exists()) { openHadithFrag(); } }); }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), (dialogInterface, i) -> dialogInterface.cancel()); dialog.show(); } }
Example 16
Source File: MainActivity.java From prayer-times-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String lang = LocaleUtils.getLanguage("en", "de", "tr"); final String file = lang + "/hadis.db"; final String url = App.API_URL + "/files/hadis." + lang + ".db"; File f = new File(App.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), file); if (f.exists()) { try { if (SqliteHelper.get().getCount() == 0) { SqliteHelper.get().close(); ((Object) null).toString(); } } catch (Exception e) { if (f.exists() && !f.delete()) { Log.e("BaseActivity", "could not delete " + f.getAbsolutePath()); } finish(); } setDefaultFragment(new HadithFragment()); moveToFrag(getDefaultFragment()); } else if (!App.isOnline()) { Toast.makeText(this, R.string.no_internet, Toast.LENGTH_SHORT).show(); } else { AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle(R.string.hadith); dialog.setMessage(getString(R.string.dlHadith)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), (dialogInterface, i) -> { File f1 = new File(App.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), file); if (!f1.getParentFile().mkdirs()) { Log.e("BaseActivity", "could not mkdirs " + f1.getParent()); } final ProgressDialog dlg = new ProgressDialog(MainActivity.this); dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dlg.setCancelable(false); dlg.setCanceledOnTouchOutside(false); dlg.show(); Ion.with(MainActivity.this).load(url).progressDialog(dlg).write(f1).setCallback((e, result) -> { dlg.dismiss(); if (e != null) { e.printStackTrace(); Crashlytics.logException(e); Toast.makeText(MainActivity.this, R.string.error, Toast.LENGTH_LONG).show(); finish(); } else if (result.exists()) { openHadithFrag(); } }); }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), (dialogInterface, i) -> dialogInterface.cancel()); dialog.show(); } }