List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:fr.mdk.kisspush.KISSPush.java
protected void openAdd() { final Activity act = this; // get prompts.xml view LayoutInflater layoutInflater = getLayoutInflater(); View promptView = layoutInflater.inflate(R.layout.prompts, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(act); // set prompts.xml to be the layout file of the alertdialog // builder//from ww w . ja v a 2s .c o m alertDialogBuilder.setView(promptView); final EditText input = (EditText) promptView.findViewById(R.id.userInput); // setup a dialog window alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to // result if (input.getText().toString().length() > 0) { kiss_push_cli.add_alias(input.getText().toString(), new JsonHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { getAliases(); } }); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create an alert dialog AlertDialog alertD = alertDialogBuilder.create(); alertD.show(); }
From source file:com.linkbubble.util.YouTubeEmbedHelper.java
AlertDialog getEmbedResultsDialog() { if (mEmbedInfo.size() > 0) { ListView listView = new ListView(mContext); listView.setAdapter(new EmbedItemAdapter()); AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setView(listView); builder.setIcon(mYouTubeResolveInfo.loadIcon(mContext.getPackageManager())); builder.setTitle(R.string.title_youtube_embed_to_load); final AlertDialog alertDialog = builder.create(); alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from w w w .j a va 2s . co m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EmbedInfo embedInfo = (EmbedInfo) view.getTag(); if (embedInfo != null) { loadYouTubeVideo(embedInfo.mId); } alertDialog.dismiss(); } }); return alertDialog; } else { final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create(); alertDialog.setTitle(R.string.youtube_embed_error_title); alertDialog.setMessage(mContext.getString(R.string.youtube_embed_error_summary)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, mContext.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); return alertDialog; } }
From source file:com.glabs.homegenie.widgets.MediaServerDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); _view = getActivity().getLayoutInflater().inflate(R.layout.widget_control_mediaserver, null); builder.setView(_view); builder.setMessage(_module.getDisplayName()) .setPositiveButton("Play", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Play to... playMediaTo();/*from w w w. ja v a 2 s .c o m*/ } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); mAdapter = new MediaFilesAdapter(_view.getContext(), R.layout.widget_control_mediaserver_item, new ArrayList<MediaEntry>()); final ListView lv = (ListView) _view.findViewById(R.id.filesList); lv.setAdapter(mAdapter); // if (navigationStack.size() == 0) { navigationStack.add("0"); } // lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { MediaEntry clicked = mAdapter.getItem(i); mAdapter.setSelectedIndex(i); _selectedMedia = null; // if (clicked.Class.indexOf("object.container") == 0) { // browse to folder _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); if (clicked.Title.equals(PARENT_FOLDER)) { navigationStack.removeLast(); } else { navigationStack.add(clicked.Id); } browseMediaFolder(lv); } else { // set current media file _selectedMedia = clicked; _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); } } }); // Control.getGroupModules("", new Control.GetGroupModulesCallback() { @Override public void groupModulesUpdated(ArrayList<Module> modules) { ArrayAdapter<CharSequence> playtoitems = new ArrayAdapter<CharSequence>(_view.getContext(), android.R.layout.simple_spinner_item); // playtoitems.add("This device"); // for (int m = 0; m < modules.size(); m++) { Module module = modules.get(m); ModuleParameter devtype = module.getParameter("UPnP.StandardDeviceType"); if (devtype != null && devtype.Value.equals("MediaRenderer")) { renderers.add(module); playtoitems.add(Control.getUpnpDisplayName(module)); } } // // Media Renderer Spinner Select Spinner playto = (Spinner) _view.findViewById(R.id.playto); playto.setAdapter(playtoitems); playto.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { _selectedMediaRender = null; if (i > 0) { _selectedMediaRender = renderers.get(i - 1); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }); // browseMediaFolder(lv); // Create the AlertDialog object and return it _dialog = builder.create(); _dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { _dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } }); return _dialog; }
From source file:co.edu.uniajc.vtf.content.ListSitesFragment.java
public Dialog createDialog() { LayoutInflater loInflater = this.getActivity().getLayoutInflater(); AlertDialog.Builder loAlert = new AlertDialog.Builder(getActivity()); loAlert.setView(loInflater.inflate(R.layout.dialog_search, null)); loAlert.setPositiveButton(R.string.general_menus_search, new DialogInterface.OnClickListener() { @Override//from w w w . j ava 2 s. c o m public void onClick(DialogInterface dialog, int id) { OptionsManager loOptions = new OptionsManager(ListSitesFragment.this.getActivity()); OptionsEntity loOptionsData = loOptions.getOptions(); EditText loSearchControl = (EditText) ((AlertDialog) dialog).findViewById(R.id.txtSearch); loOptionsData.setSearch(loSearchControl.getText().toString()); loOptions.createOrUpdateOptions(loOptionsData); ListSitesFragment.this.cboForceUpdate = true; ListSitesFragment.this.loadList(LoadActions.LOAD_DATA); dialog.dismiss(); } }); loAlert.setNegativeButton(R.string.general_menus_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); dialog.dismiss(); } }); loAlert.setNeutralButton(R.string.general_menus_clear, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { OptionsManager loOptions = new OptionsManager(ListSitesFragment.this.getActivity()); OptionsEntity loOptionsData = loOptions.getOptions(); loOptionsData.setSearch(""); loOptions.createOrUpdateOptions(loOptionsData); EditText loSearchControl = (EditText) ((AlertDialog) dialog).findViewById(R.id.txtSearch); loSearchControl.setText(""); ListSitesFragment.this.cboForceUpdate = true; ListSitesFragment.this.loadList(LoadActions.LOAD_DATA); dialog.dismiss(); } }); loAlert.setCancelable(false); return loAlert.create(); }
From source file:com.duy.pascal.ui.file.FileExplorerAction.java
public void doCreateFolder(@Nullable final FileActionListener callback) { if (mDialog != null && mDialog.isShowing()) { mDialog.cancel();// w w w .ja v a 2s. c o m } AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle(R.string.new_folder); builder.setView(R.layout.dialog_input); mDialog = builder.create(); mDialog.show(); final EditText editText = mDialog.findViewById(R.id.edit_input); TextInputLayout textInputLayout = mDialog.findViewById(R.id.hint); textInputLayout.setHint(mContext.getString(R.string.enter_new_folder_name)); Button btnOK = mDialog.findViewById(R.id.btn_ok); Button btnCancel = mDialog.findViewById(R.id.btn_cancel); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDialog.cancel(); } }); btnOK.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //get string path of in edit text String input = editText.getText().toString(); if (input.isEmpty()) { editText.setError(mContext.getString(R.string.enter_new_file_name)); return; } final File folder = new File(mExplorerContext.getCurrentDirectory(), input); boolean result = folder.mkdirs(); if (!result) { UIUtils.toast(mContext, R.string.can_not_create_folder); return; } mView.refresh(); if (callback != null) { callback.onFileSelected(new File(folder.getPath())); } destroyActionMode(); mDialog.cancel(); } }); }
From source file:com.chaosinmotion.securechat.activities.MainActivity.java
private void openNewChat() { AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = getLayoutInflater(); final View view = inflater.inflate(R.layout.dialog_chat, null); builder.setView(view); builder.setPositiveButton(R.string.newchat_chat, new DialogInterface.OnClickListener() { @Override/*from ww w. j ava 2 s. c om*/ public void onClick(DialogInterface dialog, int which) { EditText uname = (EditText) view.findViewById(R.id.username); final String username = uname.getText().toString(); if (username.equals(SCRSAManager.shared().getUsername())) { selfChatError(); } SCDeviceCache.get().devicesForSender(username, new SCDeviceCache.DeviceCallback() { @Override public void foundDevices(int userID, List<SCDeviceCache.Device> array) { if (userID != 0) { Intent intent = new Intent(MainActivity.this, ChatActivity.class); intent.putExtra("username", username); intent.putExtra("userid", userID); startActivity(intent); } } }); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Ignore } }); builder.show(); }
From source file:pl.bcichecki.rms.client.android.dialogs.EventDetailsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (event == null) { throw new IllegalStateException("Event has not been set!"); }/* w ww. jav a 2s . c o m*/ if (eventsRestClient == null) { throw new IllegalStateException("EventsRestClient has not been set!"); } if (eventsListAdapter == null) { throw new IllegalStateException("EventsListAdapter has not been set!"); } context = getActivity(); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); dialogBuilder.setTitle(getString(R.string.dialog_event_details_title, event.getTitle())); dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_event_details, null)); final boolean isUserSignedUp = event.isUserSignedUp(UserProfileHolder.getUserProfile()); dialogBuilder.setNeutralButton( isUserSignedUp ? R.string.dialog_event_details_sign_out : R.string.dialog_event_details_sign_up, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { signUp(!isUserSignedUp); } }); dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Nothing to do... } }); AlertDialog dialog = dialogBuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { TextView descriptionTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_description_text); TextView devicesTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_devices_text); TextView endsTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_ends_text); TextView participantsTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_participants_text); TextView startsTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_starts_text); TextView titleTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_title_text); TextView eventTypeTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_type_text); titleTextView.setText(event.getTitle()); startsTextView .setText(AppUtils.getFormattedDateAsString(event.getStartDate(), Locale.getDefault())); endsTextView.setText(AppUtils.getFormattedDateAsString(event.getEndDate(), Locale.getDefault())); descriptionTextView.setText(event.getDescription()); if (event.getType().equals(EventType.MEETING)) { eventTypeTextView.setText(R.string.dialog_event_details_type_meeting); } if (event.getType().equals(EventType.INTERVIEW)) { eventTypeTextView.setText(R.string.dialog_event_details_type_interview); } if (event.getParticipants() != null && event.getParticipants().size() > 0) { StringBuilder participants = new StringBuilder(); int counter = 1; for (Iterator<User> participantIterator = event.getParticipants() .iterator(); participantIterator.hasNext();) { User participant = participantIterator.next(); participants.append(counter).append(". "); if (participant.getAddress() != null && participant.getAddress().getFirstName() != null && participant.getAddress().getLastName() != null) { participants.append(participant.getAddress().getFirstName()).append(" ") .append(participant.getAddress().getLastName()); } else { participants.append(participant.getUsername()); } if (participantIterator.hasNext()) { participants.append("\n"); counter++; } } participantsTextView.setText(participants); } else { participantsTextView.setText(R.string.dialog_event_details_no_participants); } if (event.getDevices() != null && event.getDevices().size() > 0) { StringBuilder devices = new StringBuilder(); int counter = 1; for (Iterator<Device> deviceIterator = event.getDevices().iterator(); deviceIterator .hasNext();) { Device device = deviceIterator.next(); devices.append(counter).append(". "); devices.append(device.getName()); if (deviceIterator.hasNext()) { devices.append("\n"); counter++; } } devicesTextView.setText(devices); } else { devicesTextView.setText(R.string.dialog_event_details_no_devices); } } }); return dialog; }
From source file:com.esri.arcgisruntime.sample.blendrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState/* ww w.j av a 2s.c o m*/ * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle blendParameters = getArguments(); if (blendParameters != null) { mAltitude = blendParameters.getInt("altitude"); mAzimuth = blendParameters.getInt("azimuth"); mSlopeType = (SlopeType) blendParameters.getSerializable("slope_type"); mColorRampType = (ColorRamp.PresetType) blendParameters.getSerializable("color_ramp_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.dialog_title); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mAltitude, mAzimuth, mSlopeType, mColorRampType); } }); mCurrAltitudeTextView = (TextView) dialogView.findViewById(R.id.curr_altitude_text); SeekBar altitudeSeekBar = (SeekBar) dialogView.findViewById(R.id.altitude_seek_bar); altitudeSeekBar.setMax(90); //altitude is restricted to 0 - 90 //set initial altitude value updateAltitudeSeekBar(altitudeSeekBar); altitudeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAltitude = progress; updateAltitudeSeekBar(seekBar); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mCurrAzimuthTextView = (TextView) dialogView.findViewById(R.id.curr_azimuth_text); SeekBar azimuthSeekBar = (SeekBar) dialogView.findViewById(R.id.azimuth_seek_bar); azimuthSeekBar.setMax(360); //azimuth measured in degrees 0 - 360 //set initial azimuth value updateAzimuthSeekBar(azimuthSeekBar); azimuthSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAzimuth = progress; updateAzimuthSeekBar(seekBar); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); List<String> slopeTypeArray = new ArrayList<>(); slopeTypeArray.add("None"); //ordinals:0 slopeTypeArray.add("Degree"); //1 slopeTypeArray.add("Percent rise"); //2 slopeTypeArray.add("Scaled"); //3 ArrayAdapter<String> slopeTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view, slopeTypeArray); Spinner slopeTypeSpinner = (Spinner) dialogView.findViewById(R.id.slope_type_spinner); slopeTypeSpinner.setAdapter(slopeTypeSpinnerAdapter); slopeTypeSpinner.setSelection(mSlopeType.ordinal()); slopeTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mSlopeType = SlopeType.NONE; break; case 1: mSlopeType = SlopeType.DEGREE; break; case 2: mSlopeType = SlopeType.PERCENT_RISE; break; case 3: mSlopeType = SlopeType.SCALED; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); List<String> colorRampTypeArray = new ArrayList<>(); colorRampTypeArray.add("None"); //ordinals:0 colorRampTypeArray.add("Elevation"); //1 colorRampTypeArray.add("DEM screen"); //2 colorRampTypeArray.add("DEM light"); //3 ArrayAdapter<String> colorRampSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view, colorRampTypeArray); Spinner colorRampSpinner = (Spinner) dialogView.findViewById(R.id.color_ramp_spinner); colorRampSpinner.setAdapter(colorRampSpinnerAdapter); colorRampSpinner.setSelection(mColorRampType.ordinal()); colorRampSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mColorRampType = ColorRamp.PresetType.NONE; break; case 1: mColorRampType = ColorRamp.PresetType.ELEVATION; break; case 2: mColorRampType = ColorRamp.PresetType.DEM_SCREEN; break; case 3: mColorRampType = ColorRamp.PresetType.DEM_LIGHT; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }
From source file:ca.ualberta.app.activity.FragmentProfile.java
/** * will be called when user want to re-set the username *//* w w w.j a va2s .co m*/ private void showDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Change Author Name"); alert.setMessage("Enter Your Name Here"); final EditText input = new EditText(getActivity()); alert.setView(input); alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { newUsername = input.getEditableText().toString(); if (newUsername != null) { if (!authorMapController.hasAuthor(mcontext, newUsername)) { User.author.setUsername(newUsername); authorMapController.updateAuthor(mcontext, User.author); } else { Toast.makeText(getActivity(), "The username is aready exist, please choose another one.", Toast.LENGTH_SHORT).show(); showDialog(); } setAuthorName.setText(User.author.getUsername()); } else Toast.makeText(mcontext, "Please fill in name", Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); }
From source file:com.zbrown.droidsteal.activities.HijackActivity.java
private void selectURL() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getString(R.string.changeurl)); alert.setMessage(getString(R.string.customurl)); // Set an EditText view to get user input final EditText inputName = new EditText(this); inputName.setText(HijackActivity.this.webview.getUrl()); alert.setView(inputName); alert.setPositiveButton("Go", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { HijackActivity.this.webview.loadUrl(inputName.getText().toString()); }/*www. j a v a 2s.c o m*/ }); alert.show(); }