List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:email.schaal.ocreader.ListActivity.java
private void showAboutDialog() { View aboutView = getLayoutInflater().inflate(R.layout.dialog_about, (ViewGroup) findViewById(R.id.coordinator_layout), false); TextView textView = (TextView) aboutView.findViewById(R.id.textViewCopyright); //noinspection deprecation textView.setText(Html.fromHtml(/* ww w . j ava 2s .c o m*/ getString(R.string.about_app, getString(R.string.app_year_author), getString(R.string.app_url)))); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.drawable.ic_launcher); builder.setTitle(String.format("%s %s", getString(R.string.app_name), BuildConfig.VERSION_NAME)); builder.setView(aboutView); builder.show(); }
From source file:de.eidottermihi.rpicheck.fragment.CommandPlaceholdersDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.placeholders = this.getArguments().getStringArrayList(ARG_PLACEHOLDERS); this.command = (CommandBean) this.getArguments().getSerializable(ARG_COMMAND); this.keyPass = this.getArguments().getString(ARG_PASSPHRASE); builder.setTitle(R.string.title_placeholders); // fetching the theme-dependent icon TypedValue icon = new TypedValue(); if (getActivity().getTheme().resolveAttribute(R.attr.ic_dialog_run, icon, true)) { builder.setIcon(icon.resourceId); }// ww w . j ava 2s .c o m builder.setPositiveButton(R.string.placeholders_button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); final LayoutInflater inflater = getActivity().getLayoutInflater(); final View view = inflater.inflate(R.layout.dialog_placeholders, null); LinearLayout linLayout = (LinearLayout) view.findViewById(R.id.placeholderLayout); placeholderInputs = new HashMap<String, EditText>(); for (String string : placeholders) { final View row = inflater.inflate(R.layout.command_placeholder_row, null); final TextView placeholderName = (TextView) row.findViewById(R.id.placeholderName); placeholderName.setText(string); final EditText placeholderText = (EditText) row.findViewById(R.id.placeholderText); linLayout.addView(row); placeholderInputs.put(string, placeholderText); } builder.setView(view); return builder.create(); }
From source file:com.remdo.app.MainActivity.java
private void showAlertGPSDisabled() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.error)); builder.setMessage(getString(R.string.gps_not_enabled)); builder.setCancelable(false);// w w w .ja v a 2s.c om builder.setIcon(R.drawable.ic_alerts_and_warnings); builder.setNegativeButton(getString(R.string.close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.radicaldynamic.groupinform.activities.AccountFolderList.java
@Override protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new AlertDialog.Builder(this); Dialog dialog = null;//w ww . ja v a2 s. com switch (id) { case DIALOG_DENIED_NOT_OWNER: builder.setIcon(R.drawable.ic_dialog_info).setTitle(R.string.tf_unable_to_edit_folder_not_owner_title) .setMessage(R.string.tf_unable_to_edit_folder_not_owner_msg) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); dialog = builder.create(); break; case DIALOG_MORE_INFO: String message = "Owner:\n" + mFolder.getOwnerAlias() + "\n\n"; message = message + "Description:\n" + mFolder.getDescription(); builder.setIcon(R.drawable.ic_dialog_info).setTitle(mFolder.getName()).setMessage(message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DIALOG_MORE_INFO); } }); dialog = builder.create(); break; } return dialog; }
From source file:com.anandbibek.notifyme.MainActivity.java
@Override protected void onResume() { super.onResume(); if (!access) { ProgressDialog pDialog = new ProgressDialog(this); pDialog.setMessage(getResources().getString(R.string.main_check_checking)); pDialog.setMax(3000);// w w w . jav a2 s . c o m pDialog.setCancelable(false); pDialog.show(); stuff = new CheckAccessibilityTask(); stuff.execute(pDialog); return; } ListView mainFilterList = (ListView) this.findViewById(R.id.main_filter_list); String[] filterApps = new String[prefs.getNumberOfFilters() + 1]; for (int i = 0; i < filterApps.length; i++) { if (i == prefs.getNumberOfFilters()) { filterApps[i] = "JOKER"; } else { filterApps[i] = prefs.getFilterApp(i); } } ArrayAdapter<String> adapter = new MainFilterAdapter(this, filterApps); mainFilterList.setAdapter(adapter); mainFilterList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent editFilterIntent = new Intent(parent.getContext(), EditFilterActivity.class); if (position == prefs.getNumberOfFilters()) { editFilterIntent.setAction("new"); } else { editFilterIntent.setAction("edit"); editFilterIntent.putExtra("filter", position); } startActivity(editFilterIntent); } }); mainFilterList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final int filter = position; if (filter == prefs.getNumberOfFilters()) return true; final View finalView = view; AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); try { builder.setTitle(getResources().getString(R.string.main_remove_title1) + " " + ((TextView) ((RelativeLayout) view).getChildAt(1)).getText() + " " + getResources().getString(R.string.main_remove_title2)); builder.setIcon(((ImageView) ((RelativeLayout) view).getChildAt(0)).getDrawable()); } catch (Exception e) { } builder.setPositiveButton(R.string.main_remove_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { prefs.removeFilter(filter); startActivity(new Intent(finalView.getContext(), MainActivity.class).setAction("redraw")); } }); builder.setNegativeButton(R.string.main_remove_cancel, null); builder.show(); return true; } }); }
From source file:com.death.yttorrents.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); haveStoragePermission();/* w w w. ja v a2 s. co m*/ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setTitleTextColor(Color.WHITE); toolbar.setTitle(R.string.app_name); final SharedPreferences preferences = getSharedPreferences(Constants.PREFERENCE_NAME, MODE_APPEND); Boolean isFirstRun = preferences.getBoolean(Constants.PREFERENCE_KEY_FOR_FIRSTRUN, true); if (isFirstRun) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, R.style.MyDialogTheme); alertDialogBuilder.setTitle(Html.fromHtml("<font color='#ffffff'>Disclaimer/License</font>")); alertDialogBuilder.setCancelable(true); alertDialogBuilder.setMessage( Html.fromHtml("<font color='#ffffff'>" + getResources().getString(R.string.terms) + "</font>")); alertDialogBuilder.setIcon(R.drawable.ic_icon); alertDialogBuilder.setCancelable(false) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); MainActivity.this.finish(); finishActivity(0); } }).setPositiveButton("Accept", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(Constants.PREFERENCE_KEY_FOR_FIRSTRUN, false); editor.apply(); editor.commit(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setCancelable(true); alertDialog.show(); } recyclerView = (RecyclerView) findViewById(R.id.recycler_view); pDialog = new ProgressDialog(this); movies = new ArrayList<>(); mAdapter = new GalleryAdapter(getApplicationContext(), movies); mLayoutManager = new GridLayoutManager(getApplicationContext(), 2); recyclerView.addItemDecoration(new GridItemDecoration(2, UrlUtils.dpToPx(this, 5), true)); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(mAdapter); /** * Click event handler on recycler view. */ recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(), recyclerView, new GalleryAdapter.ClickListener() { @Override public void onClick(View view, int position) { Bundle bundle = new Bundle(); bundle.putSerializable("movies", movies); bundle.putInt("position", position); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance(); newFragment.setArguments(bundle); newFragment.show(ft, "slideshow"); } @Override public void onLongClick(View view, int position) { } })); fetchMovies(endpoint); }
From source file:com.svpino.longhorn.activities.DashboardActivity.java
private void addStockToWatchList(String symbol) { boolean areWeOnline = DataProvider.addStockToWatchList(getApplicationContext(), symbol); this.stockListFragment.refresh(false); if (!areWeOnline) { AlertDialog.Builder noConnectivityDialogBuilder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.dialog_message, null); TextView textView = (TextView) view.findViewById(R.id.textView); textView.setText(String.format(getString(R.string.activity_dashboard_no_connectivity_message), symbol)); noConnectivityDialogBuilder.setIcon(R.drawable.ic_warning) .setTitle(R.string.activity_dashboard_no_connectivity_title).setView(view).setCancelable(false) .setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a 2 s .com*/ public void onClick(DialogInterface dialog, int which) { } }); this.noConnectivityDialog = noConnectivityDialogBuilder.create(); this.noConnectivityDialog.show(); } }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private void showVersionInfo() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")"); builder.setMessage(getVersionInfo(false)); builder.setIcon(R.drawable.ic_launcher); builder.setPositiveButton(getString(android.R.string.copy), new DialogInterface.OnClickListener() { @Override/* w w w. j ava 2s .c o m*/ public void onClick(DialogInterface dialog, int which) { DeprecatedUtils.setClipboard(getBaseContext(), getVersionInfo(true)); } }); builder.create().show(); }
From source file:cm.aptoide.pt.ManageRepo.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { LayoutInflater li = LayoutInflater.from(this); switch (item.getItemId()) { case ADD_REPO: View view = li.inflate(R.layout.addrepo, null); final TextView sec_msg = (TextView) view.findViewById(R.id.sec_msg); final TextView sec_msg2 = (TextView) view.findViewById(R.id.sec_msg2); final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); }/* ww w.ja v a2 s.com*/ } }); Builder p = new AlertDialog.Builder(this).setView(view); alrt = p.create(); alrt.setIcon(android.R.drawable.ic_menu_add); alrt.setTitle("Add new repository"); alrt.setButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Message msg = new Message(); EditText uri = (EditText) alrt.findViewById(R.id.edit_uri); String uri_str = uri.getText().toString(); sec_msg.setVisibility(View.GONE); sec_msg2.setVisibility(View.GONE); if (sec.isChecked()) { String user = sec_user.getText().toString(); String pwd = sec_pwd.getText().toString(); int result = checkServer(uri_str, user, pwd); if (result == 200) { msg.obj = 0; db.addServer(uri_str); db.addLogin(user, pwd, uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login is wrong"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } else { int result = checkServer(uri_str, null, null); if (result == 200) { msg.obj = 0; db.addServer(uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login required"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } new_repo.sendMessage(msg); } }); alrt.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); break; case REM_REPO: final Vector<String> rem_lst = new Vector<String>(); CharSequence[] b = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b[i] = server_lst.get(i).uri; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Chose repository to remove"); builder.setIcon(android.R.drawable.ic_menu_close_clear_cancel); builder.setMultiChoiceItems(b, null, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if (isChecked) { rem_lst.addElement(server_lst.get(whichButton).uri); } else { rem_lst.removeElement(server_lst.get(whichButton).uri); } } }); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { db.removeServer(rem_lst); change = true; redraw(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = builder.create(); alert.show(); break; case EDIT_REPO: CharSequence[] b2 = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b2[i] = server_lst.get(i).uri; } AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Chose repository to edit"); builder2.setIcon(android.R.drawable.ic_menu_edit); builder2.setSingleChoiceItems(b2, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updt_repo = server_lst.get(which).uri; } }); builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editRepo(updt_repo); return; } }); builder2.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); alert2 = builder2.create(); alert2.show(); break; } return super.onMenuItemSelected(featureId, item); }
From source file:br.com.GUI.perfil.SelecionarTipoDeLogin.java
@SuppressWarnings("deprecation") public void loginComFacebook() { clearFbData();/*from w w w . j av a2 s . c om*/ //Log.i("clicou", "logarComFacebook"); Log.i("issessionvalid", " " + String.valueOf(facebook.isSessionValid())); if (facebook.isSessionValid()) { getProfileInformation(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Carregando"); alertDialog.setMessage("Carregando informaes... Por favor, Espere alguns momentos..."); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } else { String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } if (!facebook.isSessionValid()) { facebook.authorize(this, new String[] { "publish_stream" }, new DialogListener() { //"name","email","gender","username" @Override public void onCancel() { // Function to handle cancel event } @Override public void onComplete(Bundle values) { // Function to handle complete event // Edit Preferences and update facebook acess_token SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit(); //Log.i("entrei aki ", "entrei no on complete"); getProfileInformation(); } @Override public void onError(DialogError error) { // Function to handle error } @Override public void onFacebookError(FacebookError fberror) { // Function to handle Facebook errors } }); } } }