List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:vendor.VendorHomeActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment;//www . jav a 2 s . co m Bundle bundle; FragmentManager fragmentManager; switch (position) { case 0: fragment = new VendorHomeFragmet(); bundle = new Bundle(); // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(bundle); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mFarmerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); break; case 1: fragment = new VendorBuyFragmet(); bundle = new Bundle(); // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(bundle); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mFarmerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); break; case 2: fragment = new VendorSellFragmet(); bundle = new Bundle(); // bundle.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(bundle); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mFarmerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); break; case 3: AlertDialog.Builder bulder = new AlertDialog.Builder(VendorHomeActivity.this); bulder.setTitle("Are you sure ?...."); bulder.setIcon(R.drawable.ic_launcher); bulder.setMessage("You want to Logout"); bulder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Intent intent = new Intent(VendorHomeActivity.this, MainActivity.class); startActivity(intent); } }); bulder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Toast.makeText(VendorHomeActivity.this, "Welldone", Toast.LENGTH_LONG).show(); dialog.dismiss(); } }); AlertDialog d = bulder.create(); d.show(); break; default: break; } }
From source file:com.restswitch.controlpanel.MainActivity.java
private void alertInfo(String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Information"); builder.setMessage(msg);//from w w w. j a v a 2s.c om builder.setNeutralButton("OK", null); builder.setIcon(android.R.drawable.ic_dialog_info); builder.show(); }
From source file:com.bti360.hackathon.listview.HackathonActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case ADD_DIALOG: // We are going to create an AlertDialog with a single text input and a button // first we create the EditText final EditText edit = new EditText(this); // Next we create an AlertDialog.Builder which creates a styled AlertDialog based // on our specifications; AlertDialog.Builder builder = new AlertDialog.Builder(this); // set the title builder.setTitle("Add Person"); // set the icon to a built-in, this one is a + builder.setIcon(android.R.drawable.ic_input_add); // set the text of the only button, and add a click listener builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override/* www . ja v a 2s. c o m*/ public void onClick(DialogInterface dialog, int which) { // on the Ok Button we grab the text from the EditText, // clear it and then add the Name to our list String name = edit.getText().toString(); edit.setText(""); addName(name); } }); // finally let's create the dialog final AlertDialog d = builder.create(); // and set the view to our EditText d.setView(edit); // we'll set a special InputType since we are collecting a name // other's exist such as email, address, phone number, etc // this allows the IME (keyboard) to customize itself based on // expected input, e.g. show @ and .com when Email edit.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); // Respond to the default action on the IME (keyboard) By default it is // "Done" but it can be changed with setImeActionLabel to be something // else like a search hourglass. // In our case we want a click on "Done" to do the same thing as a click // on the Ok button in the Dialog. edit.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView tv, int actionId, KeyEvent arg2) { // same as the DialogClick Handler except we also dismiss the dialog String name = edit.getText().toString(); edit.setText(""); addName(name); d.dismiss(); return true; } }); return d; } return super.onCreateDialog(id); }
From source file:net.granoeste.scaffold.app.ScaffoldAlertDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { int iconId = getArguments().getInt(ICON_ID, 0); String title = getArguments().getString(TITLE); String message = getArguments().getString(MESSAGE); boolean hasPositive = getArguments().getBoolean(HAS_POSITIVE, false); boolean hasNeutral = getArguments().getBoolean(HAS_NEUTRAL, false); boolean hasNegative = getArguments().getBoolean(HAS_NEGATIVE, false); String positiveText = getArguments().getString(POSITIVE_TEXT); String neutralText = getArguments().getString(NEUTRAL_TEXT); String negativeText = getArguments().getString(NEGATIVE_TEXT); boolean cancelable = getArguments().getBoolean(CANCELABLE, true); boolean canceledOnTouchOutside = getArguments().getBoolean(CANCELED_ON_TOUCH_OUTSIDE, false); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (iconId > 0) { builder.setIcon(iconId); }/*w w w. j a v a2 s.co m*/ if (StringUtils.isNoneEmpty(title)) { builder.setTitle(title); } if (StringUtils.isNoneEmpty(message)) { builder.setMessage(message); } if (hasPositive) { if (StringUtils.isEmpty(positiveText)) { positiveText = getResources().getString(R.string.yes); } builder.setPositiveButton(positiveText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } if (hasNeutral) { if (StringUtils.isEmpty(neutralText)) { neutralText = getResources().getString(R.string.no); } builder.setNeutralButton(neutralText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } if (hasNegative) { if (StringUtils.isEmpty(negativeText)) { negativeText = getResources().getString(hasNeutral ? R.string.cancel : R.string.no); } builder.setNegativeButton(negativeText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } builder.setCancelable(cancelable); if (cancelable) { builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogCancel(dialog, getTag()); } } } }); } // View customView = getCustomView(); if (mCustomView != null) { builder.setView(mCustomView); } Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(canceledOnTouchOutside); return dialog; }
From source file:in.suraj.timetableswipe.MainActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.about: final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); // Setting Dialog Title alertDialog.setTitle("About TimeTable"); // Setting Dialog Message alertDialog//w ww .ja v a 2 s .c o m .setMessage("Time table of IT dept\nDeveloped by: Suraj Patil\nContact: Dept of IT, SGGSIET"); // Setting Icon to Dialog alertDialog.setIcon(R.drawable.ic_action_about); // Setting Positive "Yes" Button alertDialog.setPositiveButton("OK", null); // Showing Alert Message alertDialog.show(); return true; } return false; }
From source file:org.fdroid.fdroid.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_APPDETAILS: break;/* ww w . j av a2 s . c om*/ case REQUEST_MANAGEREPOS: if (data != null && data.hasExtra(ManageReposActivity.REQUEST_UPDATE)) { AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this); ask_alrt.setTitle(getString(R.string.repo_update_title)); ask_alrt.setIcon(android.R.drawable.ic_menu_rotate); ask_alrt.setMessage(getString(R.string.repo_alrt)); ask_alrt.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { updateRepos(); } }); ask_alrt.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }); AlertDialog alert = ask_alrt.create(); alert.show(); } break; case REQUEST_PREFS: // The automatic update settings may have changed, so reschedule (or // unschedule) the service accordingly. It's cheap, so no need to // check if the particular setting has actually been changed. UpdateService.schedule(getBaseContext()); if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) { ((FDroidApp) getApplication()).reloadTheme(); final Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); finish(); overridePendingTransition(0, 0); startActivity(intent); } break; case REQUEST_ENABLE_BLUETOOTH: fdroidApp.sendViaBluetooth(this, resultCode, "org.fdroid.fdroid"); break; } if (requestCode == com.skubit.Utils.AUTHORIZATION_CODE && data != null && !TextUtils.isEmpty(data.getStringExtra("response"))) { com.skubit.Utils.createNewAccount(this, data); } else if (requestCode == com.skubit.Utils.PLAY_CODE) { doLogin = true; bindService(com.skubit.Utils.getBillingServiceIntent(), mServiceConn, Context.BIND_AUTO_CREATE); } }
From source file:com.yeldi.yeldibazaar.FDroid.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_APPDETAILS: break;/*from ww w . j av a 2 s.c o m*/ case REQUEST_MANAGEREPOS: if (data.hasExtra("update")) { AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this); ask_alrt.setTitle(getString(R.string.repo_update_title)); ask_alrt.setIcon(android.R.drawable.ic_menu_rotate); ask_alrt.setMessage(getString(R.string.repo_alrt)); ask_alrt.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { updateRepos(); } }); ask_alrt.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = ask_alrt.create(); alert.show(); } break; case REQUEST_PREFS: // The automatic update settings may have changed, so reschedule // (or // unschedule) the service accordingly. It's cheap, so no need // to // check if the particular setting has actually been changed. UpdateService.schedule(getBaseContext()); if (data != null && data.hasExtra("update")) { updateRepos(); } else if (data != null && data.hasExtra("restart")) { final Intent intent = getIntent(); overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); finish(); overridePendingTransition(0, 0); startActivity(intent); } else { repopulateViews(); } break; } }
From source file:com.death.yttorrents.activity.MainActivity.java
/** * @param item//from w w w .j av a2 s . c o m * @return */ @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.seedr) { count += 1; Toast.makeText(MainActivity.this, "Sorting by minimum rating 8 on page " + count, Toast.LENGTH_SHORT) .show(); String url = "https://yts.ag/api/v2/list_movies.json?minimum_rating=8&limit=50&page=" + count; fetchMovies(url); } if (item.getItemId() == R.id.search) { count = 0; LayoutInflater li = LayoutInflater.from(MainActivity.this); View dialogView = li.inflate(R.layout.custom_query, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this, R.style.MyDialogTheme); alertDialogBuilder.setTitle(Html.fromHtml("<font color='#ffffff'>Search Movie</font>")); alertDialogBuilder.setIcon(R.drawable.ic_icon); alertDialogBuilder.setView(dialogView); final EditText userInput = (EditText) dialogView.findViewById(R.id.et_input); alertDialogBuilder.setCancelable(false) .setPositiveButton("Search", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { query = userInput.getText().toString(); String dataUrl = "https://yts.ag/api/v2/list_movies.json?query_term=" + query + "&limit=30"; fetchMovies(dataUrl); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } if (item.getItemId() == R.id.mwiki) { startActivity(new Intent(MainActivity.this, MediaContainer.class)); } if (item.getItemId() == R.id.about) { startActivity(new Intent(MainActivity.this, About.class)); } return super.onOptionsItemSelected(item); }
From source file:de.eidottermihi.rpicheck.fragment.PassphraseDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); this.type = this.getArguments().getString(KEY_TYPE); builder.setTitle(R.string.dialog_passphrase_needed); // fetching the theme-dependent icon TypedValue icon = new TypedValue(); if (getActivity().getTheme().resolveAttribute(R.attr.ic_dialog_passphrase, icon, true)) { builder.setIcon(icon.resourceId); }//from w w w . j a v a 2 s. c o m final LayoutInflater inflater = getActivity().getLayoutInflater(); final View view = inflater.inflate(R.layout.dialog_passphrase, null); builder.setView(view); editTextPassphrase = (EditText) view.findViewById(R.id.editTextPassphrase); checkSavePassphrase = (CheckBox) view.findViewById(R.id.checkBoxSavePassphrase); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // do nothing here } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mPassphraseDialogListener.onPassphraseCancelClick(); } }); return builder.create(); }
From source file:rs.pedjaapps.kerneltuner.ui.BuildpropEditor.java
private void addDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.add_new_entry)); //builder.setMessage("Set new value!"); builder.setIcon(R.drawable.build); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.build_add_layout, null); final EditText tvKey = (EditText) view.findViewById(R.id.key); final EditText tvValue = (EditText) view.findViewById(R.id.value); builder.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { @Override/*from w w w . jav a2 s. c o m*/ public void onClick(DialogInterface dialog, int which) { new RootUtils().exec(new RootUtils.CommandCallbackImpl() { @Override public void onComplete(RootUtils.Status status, String output) { Build build = new Build(); build.key = tvKey.getText().toString().trim(); build.value = tvValue.getText().toString().trim(); build.isProperty = true; entries.add(build); bAdapter.clear(); for (Build bld : entries) { if (bld.isProperty) bAdapter.add(bld); } bAdapter.notifyDataSetChanged(); } }, "mount -o remount,rw /system", "echo " + tvKey.getText().toString() + "=" + tvValue.getText().toString() + " >> /system/build.prop", "mount -o remount,ro /system"); } }); builder.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { } }); builder.setView(view); AlertDialog alert = builder.create(); alert.show(); }