/** * 只有拍照和选择照片两个选项 * * @param activity * @param cropImg * @param outWith * @param outHeight */ public void doPickPhotoAction(final boolean cropImg, final int outWith, final int outHeight) { this.doCrop = cropImg; this.cropWidth = outWith; this.cropHeight = outHeight; File dir = null; // showToast(activity, "若添加实时拍摄照片导致重启,请尝试在应用外拍照,再选择从相册中获取进行添加!"); String status = Environment.getExternalStorageState(); if (status.equals(Environment.MEDIA_MOUNTED)) { // 判断是否有SD卡 dir = PHOTO_DIR_SD; } else { dir = PHOTO_DIR_ROOT; } if (!dir.exists()) { dir.mkdirs(); // 创建照片的存储目录 } mCurrentPhotoFile = new File(dir, getImgName()); // 给新照的照片文件命名 // Wrap our context to inflate list items using correct theme Context dialogContext = new ContextThemeWrapper(activityContext, android.R.style.Theme_Light); String cancel = "返回"; String[] choices = new String[2]; choices[0] = "拍照"; // getString(MediaStore.ACTION_IMAGE_CAPTURE); //拍照 choices[1] = "从相册选择图片"; // getString(R.string.pick_photo); //从相册中选择 ListAdapter adapter = new ArrayAdapter<String>(dialogContext, android.R.layout.simple_list_item_1, choices); AlertDialog.Builder builder = new AlertDialog.Builder(dialogContext); builder.setTitle("选择图片"); builder.setSingleChoiceItems( adapter, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); switch (which) { case 0: { doTakePhoto(); break; } case 1: doPickPhotoFromGallery(); // 从相册中去获取 break; } } }); builder.setNegativeButton( cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
public void qtype() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Select type of measurement:"); final String[] items = getResources().getStringArray(R.array.qtype); final String[] itemsUS = getResources().getStringArray(R.array.qtypeUS); if (measureType.equalsIgnoreCase("metric")) alert.setSingleChoiceItems( items, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { qtype = items[item]; Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); else alert.setSingleChoiceItems( itemsUS, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { qtype = itemsUS[item]; Toast.makeText(getApplicationContext(), itemsUS[item], Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); AlertDialog alert_ = alert.create(); alert_.show(); }
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null; switch (id) { case DIALOG_NUM_STRINGS: // define dialog AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select Number of Strings"); StringNumChangeListener listener = new StringNumChangeListener(this); builder.setSingleChoiceItems(Fretboard.stringNumOpts, -1, listener); dialog = builder.create(); listener.setSender(dialog); break; case DIALOG_TUNING: // define dialog AlertDialog.Builder builder1 = new AlertDialog.Builder(this); builder1.setTitle("Enter Six String Tuning"); final EditText input = new EditText(this); input.setText(this._fretboard.getTuning()); TuningListener listener1 = new TuningListener(this, input); builder1.setView(input); builder1.setPositiveButton("OK", listener1); builder1.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // cancelled } }); dialog = builder1.create(); break; case DIALOG_FRET_RANGE: // define dialog AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Select First Display Fret"); FretRangeChangeListener listener2 = new FretRangeChangeListener(this); builder2.setSingleChoiceItems(Fretboard.fretRangeOpts, -1, listener2); dialog = builder2.create(); listener2.setSender(dialog); break; } return dialog; }
protected Dialog onCreateDialog(int id) { AlertDialog.Builder adb = new AlertDialog.Builder(this); switch (id) { case DIALOG_ITEMS: adb.setTitle(R.string.repeat); adb.setSingleChoiceItems(data, -1, myClickListener); break; case DIALOG_DAYS: adb.setTitle(R.string.day); adb.setSingleChoiceItems(week, -1, myClickListener); break; } adb.setPositiveButton(R.string.ok, myClickListener); return adb.create(); }
private void DialogSelectHost() { setHostSelect(0); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.host_select_dialog_title); alertDialogBuilder .setSingleChoiceItems( hostItems, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setHostSelect(whichButton); } }) .setPositiveButton( R.string.select, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editTextHost.setText(hostItems[getHostSelect()]); } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setHostSelect(0); } }); alertDialogBuilder.show(); }
public void showThemeMenu() { final ThemeManager themes = game.getThemeManager(); String[] themeMenuLabels = themes.getAvailableThemeLabels(); Integer[] themeMenuIcons = themes.getAvailableThemeIconImageIDs(); ListAdapter adapter = new ArrayAdapterWithIcons( this, android.R.layout.select_dialog_singlechoice, themeMenuLabels, themeMenuIcons); AlertDialog.Builder builder = getDialog(this); builder.setTitle("Themes Options"); builder.setPositiveButton("OK", null); builder.setSingleChoiceItems( adapter, themes.getCurrentThemeID(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { Log.d(LOGGER, "Theme Selected: " + item); if (themes.isAvailable(item)) { themes.setTheme(item); } else { purchaseItem(themes.getSkuForTheme(item)); } } }); builder.show(); }
public void showGameplayMenu() { final GameplayManager modes = game.getGameplayManager(); String[] gameplayMenuLabels = modes.getLabels(); Integer[] gameplayMenuIcons = modes.getIconImageIDs(); ListAdapter adapter = new ArrayAdapterWithIcons( this, android.R.layout.select_dialog_singlechoice, gameplayMenuLabels, gameplayMenuIcons); AlertDialog.Builder builder = getDialog(this); builder.setTitle("Gameplay Options"); builder.setPositiveButton("OK", null); builder.setSingleChoiceItems( adapter, modes.getCurrentID(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { Log.d(LOGGER, "Gameplay Selected:" + item); modes.setGameplayMode(item); game.startNewGame(false); } }); builder.show(); }
protected void setupSingleChoiceDialog(AlertDialog.Builder builder) { final List<ItemT> availableItems = getAvailableItems(); final ItemPrinter<ItemT> ip = getItemPrinter(); CharSequence[] items = new CharSequence[availableItems.size()]; for (int i = 0; i < availableItems.size(); ++i) { items[i] = ip.itemToString(availableItems.get(i)); } int checked = -1; if (selectedItems.size() > 0) { checked = selectedItems.keyAt(0); selectedItems.put(checked, getItemAt(checked)); } builder.setSingleChoiceItems( items, checked, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { selectedItems.clear(); selectedItems.put(which, getItemAt(which)); } }); }
/** Ask the user the file to import to bookmarks and history, and launch the import. */ private void importHistoryBookmarks() { List<String> exportedFiles = IOUtils.getExportedBookmarksFileList(); final String[] choices = exportedFiles.toArray(new String[exportedFiles.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setInverseBackgroundForced(true); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(getResources().getString(R.string.Commons_ImportHistoryBookmarksSource)); builder.setSingleChoiceItems( choices, 0, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { doImportHistoryBookmarks(choices[which]); dialog.dismiss(); } }); builder.setCancelable(true); builder.setNegativeButton(R.string.Commons_Cancel, null); AlertDialog alert = builder.create(); alert.show(); }
/** Shows the dialog box from which to select the sections */ @SuppressWarnings("unchecked") private void showSectionBox() { AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this); String title = mLanguageManager.getSelectSection(); builder.setTitle(title); // get it from the cache lstSection = (List<Section>) sectionCache.get(Global.SECTIONS); if (lstSection != null) { String[] sections = new String[lstSection.size()]; int i = 0; for (Section section : lstSection) { // stores the values into the array sections[i] = section.getSectionName().toString(); // checks if the section id is equal to the section id selected if (section .getSectionName() .toString() .equalsIgnoreCase(Prefs.getKey(Prefs.SECTION_NAME))) { selectionVal = i; } i++; } builder.setSingleChoiceItems(sections, selectionVal, this); builder.show(); } }
/** Opens a dialog box for language selection */ private void showLanguageBox() { AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this); builder.setTitle(SettingsActivity.this.getString(R.string.language_selection)); // Get the languages from the memcache if (mLanguageList != null) { for (int i = 0; i < mLanguageList.size(); i++) { if (langSelection != null && langSelection.trim().length() > 0) { if (mLanguageList.get(i).equalsIgnoreCase(langSelection)) { langSelectionVal = i; break; } } else if ((langSelection != null && langSelection.trim().length() <= 0) || langSelection == null) { /*if (mLanguageList.get(i).equalsIgnoreCase("English")) { langSelectionVal = i; }*/ if (mLanguageList.get(i).equalsIgnoreCase("R")) { langSelectionVal = i; } } } } builder.setSingleChoiceItems( (String[]) mLanguageList.toArray(new String[mLanguageList.size()]), langSelectionVal, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // identify which language was selected // then get the xml file for the language if (which != -1) { String selectedLanguageName = mLanguageList.get(which); String currentLanguageInManager = mLanguageManager.getStartNode(); langSelection = selectedLanguageName; // store in the shared preferences Prefs.addKey(SettingsActivity.this, Prefs.LANGUAGE_SELECTED, langSelection); if (!currentLanguageInManager.equalsIgnoreCase(selectedLanguageName)) { getLanguageXmlAsyncTask = new GetLanguageXmlAsyncTask(SettingsActivity.this, langSelection); getLanguageXmlAsyncTask.execute(); } else { txtLanguage.setText(mLanguageManager.getSelectedLanguage() + ": " + langSelection); refreshGUI(langSelection); } dialog.dismiss(); } } }); builder.show(); }
@Override public boolean onPreferenceClick(Preference preference) { // Get the current preference. int currentPreference = mApp.getSharedPreferences().getInt(Common.PLAYLISTS_LAYOUT, 0); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.playlists_layout); builder.setSingleChoiceItems( R.array.layout_preference_items, currentPreference, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mApp.getSharedPreferences() .edit() .putInt(Common.PLAYLISTS_LAYOUT, which) .commit(); dialog.dismiss(); Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_SHORT).show(); } }); builder.create().show(); return false; }
private void click03() { final String items[] = {"男", "女"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); // 先得到构造器 builder.setTitle("提示"); // 设置标题 builder.setIcon(R.drawable.info32); // 设置图标,图片id即可 builder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // dialog.dismiss(); Toast.makeText(DialogShowActivity.this, items[which], Toast.LENGTH_SHORT).show(); } }); builder.setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Toast.makeText(DialogShowActivity.this, "确定", Toast.LENGTH_SHORT).show(); } }); builder.create().show(); }
private void accountPickerDialog() { int increment = 0; for (Account account : accountManager.getAccountsByType(Constants.TWITTER_ACCOUNT_TYPE)) { acctNames[increment] = account.name; increment++; } AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle("Choose your account"); builder.setPositiveButton( "ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { twitterAccount = twitterAccounts[selected]; getTokenFromAcct(); } }); builder.setSingleChoiceItems( acctNames, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { selected = which; } }); builder.show(); }
private void selectSortMethod() { // show "select a file" dialog final String sortMethods[] = { getString(R.string.sort_by_distance), getString(R.string.sort_by_time) }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.sort_by); builder.setSingleChoiceItems( sortMethods, sortMethod, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { sortMethod = whichButton; // save current sort method in preferences SharedPreferences.Editor editor = app.getPreferences().edit(); editor.putInt("trackpoints_sort", sortMethod); editor.commit(); // resort the list waypointsArrayAdapter.notifyDataSetChanged(); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
@Override protected void onPostExecute(final ConfInfo[] possibleRecip) { mDialog.dismiss(); if (possibleRecip == null || possibleRecip.length == 0) { final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setTitle(mActivity.getString(R.string.im_no_such_recipient) + mRecip); builder.setPositiveButton(mActivity.getString(R.string.alert_dialog_ok), null); builder.create().show(); } else if (possibleRecip.length == 1) { if (mRunnable != null) { mRunnable.run(possibleRecip[0]); } } else { final String[] items = new String[possibleRecip.length]; for (int i = 0; i < items.length; ++i) { items[i] = possibleRecip[i].getNameString(); } final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setTitle(mActivity.getString(R.string.pick_a_name)); builder.setSingleChoiceItems( items, -1, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int item) { dialog.dismiss(); if (mRunnable != null) { mRunnable.run(possibleRecip[item]); } } }); builder.create().show(); } }
/** This is a callback method which will be executed on creating this fragment */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { /** Getting the arguments passed to this fragment */ Bundle bundle = getArguments(); int position = bundle.getInt("position"); /** Creating a builder for the alert dialog window */ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); /** Setting a title for the window */ builder.setTitle("Layers"); /** Setting items to the alert dialog */ builder.setSingleChoiceItems(MainActivity.layers, position, null); /** Setting a positive button and its listener */ builder.setPositiveButton("OK", positiveListener); /** Setting a positive button and its listener */ builder.setNegativeButton("Cancel", null); /** Creating the alert dialog window using the builder class */ AlertDialog dialog = builder.create(); /** Return the alert dialog window */ return dialog; }
private void showPopUpCashless() { final CharSequence[] items = {"Only Cashless", "All garages"}; AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle("Make Selection"); helpBuilder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); radioTimeSelected = item; ShowMapActivity.cashSelected = item; } }); helpBuilder.setPositiveButton( "Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show(); } }); // Remember, create doesn't show the dialog AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); }
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { final Telephone tel = this.telephones.get(arg2); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); String title = String.format(getResources().getString(R.string.call_to), tel.name); builder.setTitle(title); builder.setSingleChoiceItems( tel.toCharSequenceList(), -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int index) { Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + tel.tels.get(index))); getActivity().startActivity(intent); } }); builder.setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.create().show(); }
// Alert dialog block public void onButtonClick(View v) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); if (spnService.getSelectedItem().toString().equalsIgnoreCase("cafe")) { builder.setTitle("Cafe List"); servList = cafeList; } else if (spnService.getSelectedItem().toString().equalsIgnoreCase("pho")) { builder.setTitle("Pho List"); servList = cafeList; } else if (spnService.getSelectedItem().toString().equalsIgnoreCase("ATM")) { builder.setTitle("ATM List"); servList = ATMList; } else if (spnService.getSelectedItem().toString().equalsIgnoreCase("Fuel")) { builder.setTitle("Fuel List"); servList = fuelList; } builder.setSingleChoiceItems( servList, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { checkedItem = which; selectedPlace = servList[which].toString(); dialog.cancel(); if (selectedPlace.equalsIgnoreCase("cafe1")) { if (curLocation == null) { Log.d("Veng", "GPS not found"); AlertDialog.Builder warn = new AlertDialog.Builder(QTPlaceActivity.this); warn.setTitle("GPS Error!") .setMessage("Your GPS is not enabled") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); warn.show(); } else { OverlayItem overlayItem = new OverlayItem(curLocation, "Hello", "You're here!"); itemizeOverlay.AddOverlay(overlayItem); mapOverlays.add(itemizeOverlay); mapController.animateTo(curLocation); Route route = directions( curLocation, new GeoPoint((int) (37.422006 * 1E6), (int) (-122.074095 * 1E6))); RouteOverlay routeOverlay = new RouteOverlay(route, Color.RED); mapView.getOverlays().add(routeOverlay); Log.d("VenG", "distance"); txtDistance.setText(Integer.toString(route.getDistance())); } } } }); AlertDialog alert_dialog = builder.create(); alert_dialog.show(); alert_dialog.getListView().setItemChecked(checkedItem, true); }
private void showDialogOfSuggestedContacts(final Vector<Contact> vector) { if (vector != null) { // create content for alert ArrayList<String> array = new ArrayList<String>(); Iterator<Contact> it = vector.iterator(); while (it.hasNext()) { Contact contact = it.next(); array.add(contact.getDisplayName() + "\n" + contact.getPhoneNumber()); } AlertDialog.Builder alertContacts = new AlertDialog.Builder(this); alertContacts.setTitle("Suggessted Contacts : Pick One"); alertContacts.setSingleChoiceItems( array.toArray(new String[] {}), -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); Contact tempContact = vector.get(which); showMessage("Calling " + tempContact.getDisplayName()); callPhone(tempContact.getPhoneNumber()); } }); alertContacts.create(); alertContacts.show(); } }
/** Show a dialog for choosing the sort mode. Perform the change if required. */ private void changeSortMode() { int currentSort = PreferenceManager.getDefaultSharedPreferences(this) .getInt(Constants.PREFERENCES_BOOKMARKS_SORT_MODE, 0); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setInverseBackgroundForced(true); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(getResources().getString(R.string.BookmarksListActivity_MenuSortMode)); builder.setSingleChoiceItems( new String[] { getResources().getString(R.string.BookmarksListActivity_AlphaSortMode), getResources().getString(R.string.BookmarksListActivity_RecentSortMode) }, currentSort, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { doChangeSortMode(which); dialog.dismiss(); } }); builder.setCancelable(true); builder.setNegativeButton(R.string.Commons_Cancel, null); AlertDialog alert = builder.create(); alert.show(); }
private void showCityDialog() { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegisterActivity.this); builder.setTitle("City"); builder.setSingleChoiceItems(cityList, selectedPosition, this); alert = builder.create(); alert.show(); }
private void startScan() { log(hrProvider.getProviderName() + ".startScan()"); updateView(); deviceAdapter.deviceList.clear(); hrProvider.startScan(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Scanning"); builder.setPositiveButton( "Connect", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { log(hrProvider.getProviderName() + ".stopScan()"); hrProvider.stopScan(); connect(); updateView(); dialog.dismiss(); } }); if (hrProvider.isBondingDevice()) { builder.setNeutralButton( "Pairing", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); Intent i = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); startActivityForResult(i, 123); } }); } builder.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { log(hrProvider.getProviderName() + ".stopScan()"); hrProvider.stopScan(); load(); open(); dialog.dismiss(); updateView(); } }); builder.setSingleChoiceItems( deviceAdapter, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { HRDeviceRef hrDevice = deviceAdapter.deviceList.get(arg1); btAddress = hrDevice.getAddress(); btName = hrDevice.getName(); } }); builder.show(); }
private void doCreateText() { Log.d(TAG, "Trying to resolve name " + mRecipient.getText().toString()); if (recipientNo != 0) { new CreateTextTask().execute(); } else { ConfInfo[] users = mKom.getUsers(mRecipient.getText().toString()); ConfInfo[] confs = mKom.getConferences(mRecipient.getText().toString()); final ConfInfo[] conferences = new ConfInfo[users.length + confs.length]; if (users.length > 0) { for (int i = 0; i < users.length; i++) { conferences[i] = users[i]; } } if (confs.length > 0) { for (int i = 0; i < confs.length; i++) { conferences[i + users.length] = confs[i]; } } if (conferences != null) { if (conferences.length > 1) { Log.d(TAG, "Ambigous name"); final CharSequence[] items = new CharSequence[conferences.length]; for (int i = 0; i < conferences.length; i++) { items[i] = new String(conferences[i].getNameString()); Log.d(TAG, "Name " + i + ":" + items[i]); } AlertDialog.Builder builder = new AlertDialog.Builder(CreateNewIM.this); builder.setTitle(getString(R.string.pick_a_name)); builder.setSingleChoiceItems( items, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); dialog.cancel(); recipientNo = conferences[item].confNo; Log.d( TAG, "Selected confNo:" + recipientNo + ":" + new String(conferences[item].getNameString())); doCreateText(); } }); AlertDialog alert = builder.create(); alert.show(); } else if (conferences.length < 1) { Log.e(TAG, "No such recipient:" + mRecipient.getText().toString()); } else { recipientNo = conferences[0].confNo; new CreateTextTask().execute(); } } } }
private void showSelectAccountAlertDialog() { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null); TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title); titleTextView.setText(getString(R.string.preferences_dialog_select_account_title)); TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle); subtitleTextView.setText(getString(R.string.preferences_dialog_select_account_tips)); dialogBuilder.setCustomTitle(titleView); dialogBuilder.setPositiveButton(null, null); Account[] accounts = getGoogleAccounts(); String defAccount = getSyncAccountName(this); mOriAccounts = accounts; mHasAddedAccount = false; if (accounts.length > 0) { CharSequence[] items = new CharSequence[accounts.length]; final CharSequence[] itemMapping = items; int checkedItem = -1; int index = 0; for (Account account : accounts) { if (TextUtils.equals(account.name, defAccount)) { checkedItem = index; } items[index++] = account.name; } dialogBuilder.setSingleChoiceItems( items, checkedItem, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setSyncAccount(itemMapping[which].toString()); dialog.dismiss(); refreshUI(); } }); } View addAccountView = LayoutInflater.from(this).inflate(R.layout.add_account_text, null); dialogBuilder.setView(addAccountView); final AlertDialog dialog = dialogBuilder.show(); addAccountView.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { mHasAddedAccount = true; Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS"); intent.putExtra(AUTHORITIES_FILTER_KEY, new String[] {"gmail-ls"}); startActivityForResult(intent, -1); dialog.dismiss(); } }); }
@SuppressWarnings("unused") @Override public void onItemClick(AdapterView<?> Parent, View view, int position, long id) { // TODO Auto-generated method stub int Itemposition = Parent.getSelectedItemPosition(); int ChildCount = Parent.getChildCount(); View view1 = Parent.getChildAt(position); ViewHolder holder = (ViewHolder) view.getTag(); Txt01 = (String) holder.text01.getText(); Txt02 = (String) holder.text02.getText(); Txt03 = (String) holder.text03.getText(); AlertDialog.Builder dial = new AlertDialog.Builder(this); dial.setTitle("Que voulez vous faire avec :" + "\"" + Txt03 + "\""); dial.setIcon(R.drawable.ad_question); CharSequence[] items = {"Afficher les details", "Copier le produit dans une note"}; dial.setSingleChoiceItems( items, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { /* User clicked on a radio button do some stuff */ if (item == 0) { // afficher les details detail = true; } if (item == 1) { // créer une nouvelle note avec ce // produit newNote = true; } } }); dial.setPositiveButton( "Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (detail) { // on affiche le detail du produit gotoAffDetail(Txt01); } if (newNote) { // on supprime le produit // gotoSupprDetail(Txt01,Txt03); gotoCreateNewNote(Integer.parseInt(Txt01)); } } }); dial.show(); }
private void showPopUpDistance() { final CharSequence[] items = {"5 km", "10 km", "25 km", "50 km", "No limit"}; final int[] arrDist = {5, 10, 25, 50}; AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle("Make Selection"); helpBuilder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); radioTimeSelected = item; if (item == 4) ShowMapActivity.distSelected = -1; else ShowMapActivity.distSelected = arrDist[item]; } }); helpBuilder.setPositiveButton( "Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show(); } }); // Remember, create doesn't show the dialog AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); }
private void showPopUpManuf(CharSequence[] data) { // CharSequence[] items = {"All models","Audi","Ford","Hyundai","Mahindra & // Mahindra","Maruti","Tata"}; final CharSequence[] items = data; AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle("Make Selection"); helpBuilder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); radioTimeSelected = item; String slc = (String) items[item]; if (item == 0) ShowMapActivity.manufSelected = null; else ShowMapActivity.manufSelected = slc; } }); helpBuilder.setPositiveButton( "Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show(); } }); // Remember, create doesn't show the dialog AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); }
private void DialogSelectId() { setIdSelect(0); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.id_select_dialog_title); alertDialogBuilder .setSingleChoiceItems( idItems, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setIdSelect(whichButton); } }) .setPositiveButton( R.string.select, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editTextId.setText(idItems[getIdSelect()].toLowerCase(Locale.US)); } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setIdSelect(0); } }); alertDialogBuilder.show(); }