List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.memetro.android.alerts.CommentDialog.java
public static void showDialog(final Context context, String comment, String creator, boolean isMine, final Long id) { final Dialog mDialog = new Dialog(context); mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); mDialog.setContentView(R.layout.comment_dialog); mDialog.setCancelable(true);/* w w w. j a va 2s.c om*/ TextView titleText = (TextView) mDialog.findViewById(R.id.title); TextView messageText = (TextView) mDialog.findViewById(R.id.message); Button closeButton = (Button) mDialog.findViewById(R.id.close); Button deleteButton = (Button) mDialog.findViewById(R.id.delete); titleText.setText(titleText.getText().toString() + " " + creator); messageText.setMovementMethod(ScrollingMovementMethod.getInstance()); messageText.setText(comment); if (isMine) { deleteButton.setVisibility(View.VISIBLE); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new DeleteInBg(context, String.valueOf(id)).execute(); mDialog.dismiss(); // TODO Refrescar las alertas } }); } closeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDialog.dismiss(); } }); mDialog.show(); }
From source file:com.oliversride.wordryo.Utils.java
public static boolean getChecked(Dialog dialog, int id) { CheckBox cbx = (CheckBox) dialog.findViewById(id); return cbx.isChecked(); }
From source file:com.oliversride.wordryo.Utils.java
public static void setEnabled(Dialog dialog, int id, boolean enabled) { View view = dialog.findViewById(id); view.setEnabled(enabled);/*w ww . j a v a2s . co m*/ }
From source file:com.oliversride.wordryo.Utils.java
public static String getText(Dialog dialog, int id) { EditText editText = (EditText) dialog.findViewById(id); return editText.getText().toString(); }
From source file:com.waz.zclient.utils.ViewUtils.java
@SuppressLint("com.waz.ViewUtils") public static <T extends View> T getView(@NonNull Dialog d, @IdRes int resId) { return (T) d.findViewById(resId); }
From source file:com.oliversride.wordryo.Utils.java
public static void setChecked(Dialog dialog, int id, boolean value) { CheckBox cbx = (CheckBox) dialog.findViewById(id); cbx.setChecked(value);//from www.j ava 2s. c o m }
From source file:com.oliversride.wordryo.Utils.java
public static void setText(Dialog dialog, int id, String value) { EditText editText = (EditText) dialog.findViewById(id); if (null != editText) { editText.setText(value, TextView.BufferType.EDITABLE); }// w ww. j av a2s.c om }
From source file:de.j4velin.mapsmeasure.Dialogs.java
/** * @param m the Map/*from w w w . j a va2 s . c o m*/ * @param distance the current distance * @param area the current area * @return the units dialog */ public static Dialog getUnits(final Map m, float distance, double area) { final Dialog d = new Dialog(m); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.dialog_unit); CheckBox metricCb = (CheckBox) d.findViewById(R.id.metric); metricCb.setChecked(m.metric); metricCb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { m.metric = !m.metric; m.getSharedPreferences("settings", Context.MODE_PRIVATE).edit().putBoolean("metric", isChecked) .commit(); m.updateValueText(); } }); ((TextView) d.findViewById(R.id.distance)).setText(Map.formatter_two_dec.format(Math.max(0, distance)) + " m\n" + Map.formatter_two_dec.format(distance / 1000) + " km\n\n" + Map.formatter_two_dec.format(Math.max(0, distance / 0.3048f)) + " ft\n" + Map.formatter_two_dec.format(Math.max(0, distance / 0.9144)) + " yd\n" + Map.formatter_two_dec.format(distance / 1609.344f) + " mi\n" + Map.formatter_two_dec.format(distance / 1852f) + " nautical miles"); ((TextView) d.findViewById(R.id.area)).setText(Map.formatter_two_dec.format(Math.max(0, area)) + " m\n" + Map.formatter_two_dec.format(area / 10000) + " ha\n" + Map.formatter_two_dec.format(area / 1000000) + " km\n\n" + Map.formatter_two_dec.format(Math.max(0, area / 0.09290304d)) + " ft\n" + Map.formatter_two_dec.format(area / 4046.8726099d) + " ac (U.S. Survey)\n" + Map.formatter_two_dec.format(area / 2589988.110336d) + " mi"); d.findViewById(R.id.close).setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { d.dismiss(); } }); return d; }
From source file:net.czlee.debatekeeper.PrepTimeBellsEditActivity.java
private static Bundle createBellBundleFromAddOrEditDialog(final Dialog dialog) { final Spinner typeSpinner = (Spinner) dialog.findViewById(R.id.addPrepTimeBellDialog_typeSpinner); final TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.addPrepTimeBellDialog_timePicker); final EditText editText = (EditText) dialog.findViewById(R.id.addPrepTimeBellDialog_editText); int typeSelected = typeSpinner.getSelectedItemPosition(); Bundle bundle = new Bundle(); switch (typeSelected) { case ADD_PREP_TIME_BELL_TYPE_START: case ADD_PREP_TIME_BELL_TYPE_FINISH: // We're using this in hours and minutes, not minutes and seconds int minutes = timePicker.getCurrentHour(); int seconds = timePicker.getCurrentMinute(); long time = minutes * 60 + seconds; if (typeSelected == ADD_PREP_TIME_BELL_TYPE_START) bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_START); else/*w w w .j a va 2 s. co m*/ bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_FINISH); bundle.putLong(PrepTimeBellsManager.KEY_TIME, time); break; case ADD_PREP_TIME_BELL_TYPE_PERCENTAGE: Editable text = editText.getText(); bundle.putString(PrepTimeBellsManager.KEY_TYPE, PrepTimeBellsManager.VALUE_TYPE_PROPORTIONAL); Double percentage = Double.parseDouble(text.toString()); double value = percentage / 100; bundle.putDouble(PrepTimeBellsManager.KEY_PROPORTION, value); break; } return bundle; }
From source file:de.j4velin.mapsmeasure.Dialogs.java
/** * @param c the Context/*ww w . ja va2 s. co m*/ * @param trace the current trace of points * @return the "save & share" dialog */ public static Dialog getSaveNShare(final Activity c, final Stack<LatLng> trace) { final Dialog d = new Dialog(c); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.dialog_save); d.findViewById(R.id.save).setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final File destination; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { destination = API8Wrapper.getExternalFilesDir(c); } else { destination = c.getDir("traces", Context.MODE_PRIVATE); } d.dismiss(); AlertDialog.Builder b = new AlertDialog.Builder(c); b.setTitle(R.string.save); final View layout = c.getLayoutInflater().inflate(R.layout.dialog_enter_filename, null); ((TextView) layout.findViewById(R.id.location)) .setText(c.getString(R.string.file_path, destination.getAbsolutePath() + "/")); b.setView(layout); b.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { String fname = ((EditText) layout.findViewById(R.id.filename)).getText().toString(); if (fname == null || fname.length() < 1) { fname = "MapsMeasure_" + System.currentTimeMillis(); } final File f = new File(destination, fname + ".csv"); Util.saveToFile(f, trace); d.dismiss(); Toast.makeText(c, c.getString(R.string.file_saved, f.getAbsolutePath()), Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(c, c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()), Toast.LENGTH_LONG).show(); } } }); b.create().show(); } }); d.findViewById(R.id.load).setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { File[] files = c.getDir("traces", Context.MODE_PRIVATE).listFiles(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { File ext = API8Wrapper.getExternalFilesDir(c); // even though we checked the external storage state, ext is still sometims null, accoring to Play Store crash reports if (ext != null) { File[] filesExtern = ext.listFiles(); File[] allFiles = new File[files.length + filesExtern.length]; System.arraycopy(files, 0, allFiles, 0, files.length); System.arraycopy(filesExtern, 0, allFiles, files.length, filesExtern.length); files = allFiles; } } if (files.length == 0) { Toast.makeText(c, c.getString(R.string.no_files_found, c.getDir("traces", Context.MODE_PRIVATE).getAbsolutePath()), Toast.LENGTH_SHORT).show(); } else if (files.length == 1) { try { Util.loadFromFile(Uri.fromFile(files[0]), (Map) c); d.dismiss(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(c, c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()), Toast.LENGTH_LONG).show(); } } else { d.dismiss(); AlertDialog.Builder b = new AlertDialog.Builder(c); b.setTitle(R.string.select_file); final DeleteAdapter da = new DeleteAdapter(files, (Map) c); b.setAdapter(da, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Util.loadFromFile(Uri.fromFile(da.getFile(which)), (Map) c); dialog.dismiss(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(c, c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()), Toast.LENGTH_LONG).show(); } } }); b.create().show(); } } }); d.findViewById(R.id.share).setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { try { final File f = new File(c.getCacheDir(), "MapsMeasure.csv"); Util.saveToFile(f, trace); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(c, "de.j4velin.mapsmeasure.fileprovider", f)); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setType("text/comma-separated-values"); d.dismiss(); c.startActivity(Intent.createChooser(shareIntent, null)); } catch (IOException e) { e.printStackTrace(); Toast.makeText(c, c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()), Toast.LENGTH_LONG).show(); } } }); return d; }