List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.esri.arcgisruntime.sample.stretchrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState//w w w . j a v a2 s . co m * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle stretchParameters = getArguments(); if (stretchParameters != null) { mMin = stretchParameters.getInt("min"); mMax = stretchParameters.getInt("max"); mPercentClipMin = stretchParameters.getInt("percent_clip_min"); mPercentClipMax = stretchParameters.getInt("percent_clip_max"); mStdDevFactor = stretchParameters.getInt("std_dev_factor"); mStretchType = (MainActivity.StretchType) stretchParameters.getSerializable("stretch_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") final View dialogView = inflater.inflate(R.layout.stretch_dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.stretch_rendering_parameters); 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(mMin, mMax, mPercentClipMin, mPercentClipMax, mStdDevFactor, mStretchType); } }); // min max ui elements mMinTextView = (TextView) dialogView.findViewById(R.id.min_value_text_view); mMaxTextView = (TextView) dialogView.findViewById(R.id.max_value_text_view); mMinSeekBar = (SeekBar) dialogView.findViewById(R.id.min_seek_bar); mMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.max_seek_bar); mMinSeekBar.setMax(255); mMaxSeekBar.setMax(255); mCurrMinTextView = (TextView) dialogView.findViewById(R.id.curr_min_text_view); mCurrMaxTextView = (TextView) dialogView.findViewById(R.id.curr_max_text_view); updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // percent clip ui elements mPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.percent_clip_min_value_text_view); mPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.percent_clip_max_value_text_view); mPercentClipMinSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_min_seek_bar); mPercentClipMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_max_seek_bar); mPercentClipMinSeekBar.setMax(99); mPercentClipMaxSeekBar.setMax(99); mCurrPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_min_text_view); mCurrPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_max_text_view); updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); // standard deviation ui elements mStdDevTextView = (TextView) dialogView.findViewById(R.id.std_dev_text_view); mStdDevSeekBar = (SeekBar) dialogView.findViewById(R.id.std_dev_seek_bar); mStdDevSeekBar.setMax(3); mCurrStdDevTextView = (TextView) dialogView.findViewById(R.id.curr_std_dev_text_view); updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); // set ui to previous selection if (mStretchType == MainActivity.StretchType.MIN_MAX) { setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.PERCENT_CLIP) { setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.STANDARD_DEVIATION) { setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); } // seek bar listeners mMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMin = progress; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); // move max to march min if max goes below min if (mMax < mMin) { mMax = mMin; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMax = progress; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // move min to match max if min goes above max if (mMin > mMax) { mMin = mMax; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMin = progress; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMax = 100 - mPercentClipMin; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMax = progress; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMin = 100 - mPercentClipMax; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mStdDevSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mStdDevFactor = progress; updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // stretch type spinner List<String> stretchTypeArray = new ArrayList<>(); stretchTypeArray.add(MainActivity.StretchType.MIN_MAX.toString()); //ordinals:0 stretchTypeArray.add(MainActivity.StretchType.PERCENT_CLIP.toString()); //1 stretchTypeArray.add(MainActivity.StretchType.STANDARD_DEVIATION.toString()); //2 ArrayAdapter<String> stretchTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.stretch_spinner_text_view, stretchTypeArray); Spinner stretchTypeSpinner = (Spinner) dialogView.findViewById(R.id.stretch_type_spinner); stretchTypeSpinner.setAdapter(stretchTypeSpinnerAdapter); stretchTypeSpinner.setSelection(mStretchType.ordinal()); stretchTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mStretchType = MainActivity.StretchType.MIN_MAX; setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); break; case 1: mStretchType = MainActivity.StretchType.PERCENT_CLIP; setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); break; case 2: mStretchType = MainActivity.StretchType.STANDARD_DEVIATION; setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }
From source file:com.einzig.ipst2.activities.PSDetailsActivity.java
public void setUpImageDetailsView() { final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); portalImage.setOnClickListener(new View.OnClickListener() { @Override// www.j a v a 2 s .c om public void onClick(View view) { try { AlertDialog.Builder builder = new AlertDialog.Builder(PSDetailsActivity.this); RelativeLayout itemLayout = (RelativeLayout) LayoutInflater.from(PSDetailsActivity.this) .inflate(R.layout.image_details, null); builder.setView(itemLayout); final AlertDialog d = builder.show(); Picasso.with(PSDetailsActivity.this).load(portal.getPictureURL()) .error(R.drawable.ic_warning_white) .resize(displayMetrics.widthPixels, displayMetrics.heightPixels).centerInside() .into((ImageView) itemLayout.findViewById(R.id.bigimage_imagedetails)); itemLayout.findViewById(R.id.close_imagedetails).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { d.dismiss(); } }); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:ch.hearc.drunksum.DrunkSumActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { /*//from w w w . ja v a 2 s . co m Gre le clic sur un lment du menu */ if (item.getItemId() == R.id.reinit) { // remet la somme 0 Toast.makeText(this, "Sum reinitialized", Toast.LENGTH_SHORT).show(); mSum = 0; setTitle("Sum: " + formatter.format(mSum)); } else if (item.getItemId() == R.id.divide) { // propose de divisier la somme AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Divide sum by:"); final EditText input = new EditText(this); // n'afficher que les chiffres input.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setView(input); alert.setPositiveButton("Divide", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { double div = 0; try { // une exception survient si le texte est vide // si c'est 0, div vaut infinity div = mSum / Double.parseDouble(input.getText().toString()); } catch (Exception e) { } final Snackbar snackBar = Snackbar.make(mGraphicOverlay, "Divided sum: " + formatter.format(div), Snackbar.LENGTH_INDEFINITE); snackBar.setAction("OK", new View.OnClickListener() { @Override public void onClick(View v) { snackBar.dismiss(); } }); snackBar.show(); } }); alert.show(); } return true; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * // w w w .ja v a 2s . com * @return */ @Override protected Dialog createCPUDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createCPUListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(CPU_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("CPU usages"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a view to display disk status.//from w w w . j av a 2 s . c om * * @return a AlertDialog containing the view. */ @Override protected Dialog createDiskDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createDiskListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DISK_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("Disk usage"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a view to display disk status./*from w w w . j a v a 2 s. co m*/ * * @return a AlertDialog containing the view. */ @Override protected Dialog createDiskBusyDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createDiskBusyListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DISK_BUSY_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("Disk busy"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.brayanarias.alarmproject.activity.MainActivity.java
private void setupNavigationView() { navigationView = (NavigationView) findViewById(R.id.navigation); MenuItem item = navigationView.getMenu().findItem(actualItem); View nav_header = LayoutInflater.from(this).inflate(R.layout.nav_header, null); final NavigationView navigationView = (NavigationView) findViewById(R.id.navigation); navigationView.addHeaderView(nav_header); //salute//from www .jav a 2 s . c om String salute = AlarmUtilities.getSalute(getApplicationContext()); TextView tvWellcome = (TextView) nav_header.findViewById(R.id.tvWellcome); tvWellcome.setText(salute); if (item != null) { item.setChecked(true); } navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { CharSequence title = menuItem.getTitle(); closeDrawer(); switch (menuItem.getItemId()) { case R.id.itMyAlarms: showFragment(R.id.itMyAlarms); actualItem = menuItem.getItemId(); menuItem.setChecked(true); getSupportActionBar().setTitle(title); return true; case R.id.itAddAlarm: Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); TimePickerDialog timePickerDialog = TimePickerDialog .newInstance(new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) { Alarm alarm = AlarmUtilities.createDefaultAlarm(); String min = minute < 10 ? "0" + minute : "" + minute; if (hourOfDay == 12) { alarm.setAmPm("PM"); alarm.setHour(hourOfDay); alarm.setHourFormatted((hourOfDay) + ":" + min); } else if (hourOfDay > 12) { alarm.setAmPm("PM"); alarm.setHour(hourOfDay - 12); alarm.setHourFormatted((hourOfDay - 12) + ":" + min); } else { if (hourOfDay == 0) { hourOfDay = 12; } alarm.setAmPm("AM"); alarm.setHour(hourOfDay); alarm.setHourFormatted(hourOfDay + ":" + min); } alarm.setMinute(minute); Intent intent = new Intent(getApplicationContext(), AddAlarmActivity.class); intent.putExtra(Constant.actionAlarmKey, Constant.addAlarm); intent.putExtra(Constant.alarmSerializableKey, alarm); startActivity(intent); } }, hour, minute, false); timePickerDialog.show(getSupportFragmentManager(), "tag"); return true; case R.id.itCurrentMonth: actualItem = menuItem.getItemId(); menuItem.setChecked(true); showFragment(R.id.itCurrentMonth); getSupportActionBar().setTitle(title); return true; /* case R.id.itConfig: actualItem = menuItem.getItemId(); menuItem.setChecked(true); showFragment(R.id.itConfig); getSupportActionBar().setTitle(title); closeDrawer(); return true; */ case R.id.itAbout: AlertDialog.Builder alertBuilder = new AlertDialog.Builder(MainActivity.this); WebView wvLegal = (WebView) LayoutInflater.from(getApplication()) .inflate(R.layout.web_view_legal, null); wvLegal.loadData(getString(R.string.html_legal), "text/html", "UTF-8"); wvLegal.setWebChromeClient(new WebChromeClient()); alertBuilder.setView(wvLegal); alertBuilder.setTitle(R.string.txt_about_app); alertBuilder.setCancelable(true).setPositiveButton(getString(R.string.txt_button_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alertBuilder.show(); return true; default: return false; } } }); }
From source file:at.tomtasche.reader.ui.widget.RecentDocumentDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new Builder(getActivity()); builder.setTitle(R.string.dialog_recent_title); builder.setCancelable(true);/* w w w . ja v a 2 s.c om*/ TextView emptyView = new TextView(getActivity()); emptyView.setText(R.string.dialog_loading_title); listView = new ListView(getActivity()); listView.setEmptyView(emptyView); listView.setOnItemClickListener(this); listView.setOnItemLongClickListener(this); adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, new String[0]); listView.setAdapter(adapter); builder.setView(listView); setCancelable(true); items = new HashMap<String, String>(); loadRecentDocuments(); listView.setEmptyView(emptyView); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.AddEQPresetDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mApp = (Common) getActivity().getApplicationContext(); mEqualizerFragment = (EqualizerActivity) getActivity(); dialog = this; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); dialogView = getActivity().getLayoutInflater().inflate(R.layout.add_new_equalizer_preset_dialog_layout, null);/*from www . j a va2 s. c o m*/ newPresetNameField = (EditText) dialogView.findViewById(R.id.new_preset_name_text_field); newPresetNameField.setTypeface(TypefaceHelper.getTypeface(getActivity(), "Roboto-Light")); newPresetNameField.setPaintFlags( newPresetNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Set the dialog title. builder.setTitle(R.string.new_eq_preset); builder.setView(dialogView); builder.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialog.dismiss(); } }); builder.setPositiveButton(R.string.done, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Get the preset name from the text field. String presetName = newPresetNameField.getText().toString(); //Add the preset and it's values to the DB. mApp.getDBAccessHelper().addNewEQPreset(presetName, mEqualizerFragment.getFiftyHertzLevel(), mEqualizerFragment.getOneThirtyHertzLevel(), mEqualizerFragment.getThreeTwentyHertzLevel(), mEqualizerFragment.getEightHundredHertzLevel(), mEqualizerFragment.getTwoKilohertzLevel(), mEqualizerFragment.getFiveKilohertzLevel(), mEqualizerFragment.getTwelvePointFiveKilohertzLevel(), (short) mEqualizerFragment.getVirtualizerSeekBar().getProgress(), (short) mEqualizerFragment.getBassBoostSeekBar().getProgress(), (short) mEqualizerFragment.getReverbSpinner().getSelectedItemPosition()); Toast.makeText(getActivity(), R.string.preset_saved, Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); return builder.create(); }