List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.eyekabob.util.EyekabobHelper.java
public static Dialog createAboutDialog(Context context) { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dialog); dialog.setTitle(R.string.about_eyekabob_caps); ImageView imageView = (ImageView) dialog.findViewById(R.id.aboutDialogImage); imageView.setImageResource(R.drawable.ic_launcher); String message = context.getResources().getString(R.string.eyekabob_version); String versionName = ""; try {// ww w .ja v a2s. c o m versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { Log.e(context.getClass().getSimpleName(), e.getMessage()); } message += versionName; message += "\n\n" + context.getResources().getString(R.string.about_eyekabob_app); message += "\n\n" + context.getResources().getString(R.string.about_last_fm); TextView textView = (TextView) dialog.findViewById(R.id.aboutDialogText); textView.setText(message); dialog.findViewById(R.id.aboutDialogButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); return dialog; }
From source file:fi.tuukka.weather.utils.Utils.java
public static void showImage(Activity activity, View view, Bitmap bmp) { final Dialog imageDialog = new Dialog(activity); imageDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); imageDialog.setContentView(R.layout.showimage); imageDialog.setCancelable(true);// ww w . j a v a 2s . c o m ImageView imageView = (ImageView) imageDialog.findViewById(R.id.imageView); // Getting width & height of the given image. DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics(); int wn = displayMetrics.widthPixels; int hn = displayMetrics.heightPixels; int wo = bmp.getWidth(); int ho = bmp.getHeight(); Matrix mtx = new Matrix(); // Setting rotate to 90 mtx.preRotate(90); // Setting resize mtx.postScale(((float) 1.3 * wn) / ho, ((float) 1.3 * hn) / wo); // Rotating Bitmap Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, wo, ho, mtx, true); BitmapDrawable bmd = new BitmapDrawable(rotatedBMP); imageView.setImageDrawable(bmd); imageView.setOnClickListener(new View.OnClickListener() { public void onClick(View button) { imageDialog.dismiss(); } }); imageDialog.show(); }
From source file:com.spoiledmilk.ibikecph.util.Util.java
public static void launchNoConnectionDialog(Context ctx) { final Dialog dialog = new Dialog(ctx); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_no_connection); TextView text = (TextView) dialog.findViewById(R.id.textNetworkError); text.setTypeface(IbikeApplication.getNormalFont()); text.setText(IbikeApplication.getString("network_error_text")); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.show();// www . j a v a 2 s .co m final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { try { dialog.dismiss(); } catch (Exception e) { // dialog not attached to window } } }, 3000); }
From source file:com.normsstuff.maps4norm.Dialogs.java
/** * @param c the Context/*from w w w .j a v a2s.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.saveMarks).setOnClickListener(new OnClickListener() { @Override public void onClick(final View vX) { 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.loadMarks).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 sometimes 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]), (MyMapActivity) 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, (MyMapActivity) c); b.setAdapter(da, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Util.loadFromFile(Uri.fromFile(da.getFile(which)), (MyMapActivity) 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; }
From source file:in.shick.diode.common.util.Util.java
public static void setStateOfUpvoteDownvoteButtons(Dialog theDialog, boolean isLoggedIn, ThingInfo theThingInfo, CompoundButton.OnCheckedChangeListener upvoteListener, CompoundButton.OnCheckedChangeListener downvoteListener) { final CheckBox voteUpButton = (CheckBox) theDialog.findViewById(R.id.vote_up_button); final CheckBox voteDownButton = (CheckBox) theDialog.findViewById(R.id.vote_down_button); // Only show upvote/downvote if user is logged in if (isLoggedIn) { voteUpButton.setVisibility(View.VISIBLE); voteDownButton.setVisibility(View.VISIBLE); // Remove the OnCheckedChangeListeners because we are about to setChecked(), // and I think the Buttons are recycled, so old listeners will fire // for the previous vote target ThingInfo. voteUpButton.setOnCheckedChangeListener(null); voteDownButton.setOnCheckedChangeListener(null); // Set initial states of the vote buttons based on user's past actions if (theThingInfo.getLikes() == null) { // User is currently neutral voteUpButton.setChecked(false); voteDownButton.setChecked(false); } else if (theThingInfo.getLikes()) { // User currenty likes it voteUpButton.setChecked(true); voteDownButton.setChecked(false); } else {/*www . ja v a 2s. c o m*/ // User currently dislikes it voteUpButton.setChecked(false); voteDownButton.setChecked(true); } voteUpButton.setEnabled(!theThingInfo.isArchived()); voteDownButton.setEnabled(!theThingInfo.isArchived()); if (!theThingInfo.isArchived()) { voteUpButton.setOnCheckedChangeListener(upvoteListener); voteDownButton.setOnCheckedChangeListener(downvoteListener); } } else { voteUpButton.setVisibility(View.GONE); voteDownButton.setVisibility(View.GONE); } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java
final static private String getDayOfTheWeekString(final GlobalParameters mGlblParms, Dialog dialog) { CheckBox cb_dw_mon = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_monday); CheckBox cb_dw_tue = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_tuesday); CheckBox cb_dw_wed = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_wedsday); CheckBox cb_dw_thu = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_thursday); CheckBox cb_dw_fri = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_friday); CheckBox cb_dw_sat = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_satday); CheckBox cb_dw_sun = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_sunday); String prof_dw_mon = "0", prof_dw_tue = "0", prof_dw_wed = "0", prof_dw_thu = "0", prof_dw_fri = "0", prof_dw_sat = "0", prof_dw_sun = "0"; if (cb_dw_mon.isChecked()) prof_dw_mon = "1"; if (cb_dw_tue.isChecked()) prof_dw_tue = "1"; if (cb_dw_wed.isChecked()) prof_dw_wed = "1"; if (cb_dw_thu.isChecked()) prof_dw_thu = "1"; if (cb_dw_fri.isChecked()) prof_dw_fri = "1"; if (cb_dw_sat.isChecked()) prof_dw_sat = "1"; if (cb_dw_sun.isChecked()) prof_dw_sun = "1"; mGlblParms.util.addDebugMsg(1, "I", "getDayOfTheWeekString result=" + prof_dw_mon + prof_dw_tue + prof_dw_wed + prof_dw_thu + prof_dw_fri + prof_dw_sat + prof_dw_sun); return prof_dw_sun + prof_dw_mon + prof_dw_tue + prof_dw_wed + prof_dw_thu + prof_dw_fri + prof_dw_sat; }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java
final static private void setDayOfTheWeekCheckBox(final GlobalParameters mGlblParms, Dialog dialog, String dw) { CheckBox cb_dw_mon = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_monday); CheckBox cb_dw_tue = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_tuesday); CheckBox cb_dw_wed = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_wedsday); CheckBox cb_dw_thu = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_thursday); CheckBox cb_dw_fri = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_friday); CheckBox cb_dw_sat = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_satday); CheckBox cb_dw_sun = (CheckBox) dialog.findViewById(R.id.edit_profile_time_day_of_the_week_sunday); if (dw.substring(0, 1).equals("1")) cb_dw_sun.setChecked(true);//from w w w .j ava 2 s . c o m if (dw.substring(1, 2).equals("1")) cb_dw_mon.setChecked(true); if (dw.substring(2, 3).equals("1")) cb_dw_tue.setChecked(true); if (dw.substring(3, 4).equals("1")) cb_dw_wed.setChecked(true); if (dw.substring(4, 5).equals("1")) cb_dw_thu.setChecked(true); if (dw.substring(5, 6).equals("1")) cb_dw_fri.setChecked(true); if (dw.substring(6, 7).equals("1")) cb_dw_sat.setChecked(true); mGlblParms.util.addDebugMsg(1, "I", "setDayOfTheWeekCheckBox dw=" + dw); }
From source file:com.frostwire.android.gui.views.AbstractDialog.java
@SuppressWarnings("unchecked") protected final <T extends View> T findView(Dialog dlg, int id) { return (T) dlg.findViewById(id); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java
final static private void setViewVisibilityByDateTimeType(final GlobalParameters mGlblParms, Dialog dialog, String repeat_type) {/*from w w w . ja v a2 s . co m*/ LinearLayout ll_dw = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_day_of_the_week); LinearLayout ll_exec_year = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_ll_exec_year); LinearLayout ll_exec_month = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_ll_exec_month); LinearLayout ll_exec_day = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_ll_exec_day); LinearLayout ll_exec_hour = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_ll_exec_hour); LinearLayout ll_exec_ymd = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_ll_exec_ymd); LinearLayout ll_exec_hm = (LinearLayout) dialog.findViewById(R.id.edit_profile_time_ll_exec_hm); ll_dw.setVisibility(LinearLayout.VISIBLE); ll_exec_year.setVisibility(Spinner.VISIBLE); ll_exec_month.setVisibility(Spinner.VISIBLE); ll_exec_day.setVisibility(Spinner.VISIBLE); ll_exec_hour.setVisibility(Spinner.VISIBLE); ll_exec_ymd.setVisibility(LinearLayout.VISIBLE); ll_exec_hm.setVisibility(LinearLayout.VISIBLE); if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_ONE_SHOT)) { ll_dw.setVisibility(LinearLayout.GONE); } else if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_EVERY_YEAR)) { ll_dw.setVisibility(LinearLayout.GONE); ll_exec_year.setVisibility(Spinner.GONE); } else if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_EVERY_MONTH)) { ll_dw.setVisibility(LinearLayout.GONE); ll_exec_year.setVisibility(Spinner.GONE); ll_exec_month.setVisibility(Spinner.GONE); } else if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_DAY_OF_THE_WEEK)) { ll_exec_year.setVisibility(Spinner.GONE); ll_exec_month.setVisibility(Spinner.GONE); ll_exec_day.setVisibility(Spinner.GONE); ll_exec_ymd.setVisibility(LinearLayout.GONE); } else if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_EVERY_DAY)) { ll_dw.setVisibility(LinearLayout.GONE); ll_exec_year.setVisibility(Spinner.GONE); ll_exec_month.setVisibility(Spinner.GONE); ll_exec_day.setVisibility(Spinner.GONE); ll_exec_ymd.setVisibility(LinearLayout.GONE); } else if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_EVERY_HOUR)) { ll_dw.setVisibility(LinearLayout.GONE); ll_exec_year.setVisibility(Spinner.GONE); ll_exec_month.setVisibility(Spinner.GONE); ll_exec_day.setVisibility(Spinner.GONE); ll_exec_hour.setVisibility(Spinner.GONE); ll_exec_ymd.setVisibility(LinearLayout.GONE); } else if (repeat_type.equals(PROFILE_DATE_TIME_TYPE_INTERVAL)) { ll_dw.setVisibility(LinearLayout.GONE); ll_exec_year.setVisibility(Spinner.GONE); ll_exec_month.setVisibility(Spinner.GONE); ll_exec_day.setVisibility(Spinner.GONE); ll_exec_ymd.setVisibility(LinearLayout.GONE); } }
From source file:com.vrem.wifianalyzer.wifi.filter.EnumFilter.java
private void setInformation(@NonNull Dialog dialog, int id, @NonNull T object) { View view = dialog.findViewById(id); view.setOnClickListener(new OnClickListener(object)); setColor(view, object);// www.java 2 s . co m }