List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java
protected void applicenseDialog() { final Dialog aLDialog = new Dialog(IntroActivity.this); aLDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); aLDialog.setTitle("License Agreement"); aLDialog.setCancelable(false);/* w ww . j a v a2s . c o m*/ aLDialog.setCanceledOnTouchOutside(false); aLDialog.setContentView(R.layout.app_license_dialog); WebView lic = (WebView) aLDialog.findViewById(R.id.atomizeLic); Button disagree = (Button) aLDialog.findViewById(R.id.alDialogDisagree); Button agree = (Button) aLDialog.findViewById(R.id.alDialogAgree); lic.getSettings().setUseWideViewPort(true); lic.loadUrl("file:///android_asset/atomizeLicense.html"); disagree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { aLDialog.dismiss(); SharedPreferences.Editor e = getPrefs.edit(); e.putBoolean("agreedToLicense", false); e.apply(); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(homeIntent); IntroActivity.this.finish(); MainActivity.getInstance().finish(); } }); agree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences.Editor e = getPrefs.edit(); e.putBoolean("agreedToLicense", true); e.apply(); aLDialog.dismiss(); } }); aLDialog.show(); }
From source file:com.yammy.meter.MainActivity.java
private void showAlert() { final Dialog myDialog = new Dialog(this); myDialog.setContentView(R.layout.isvo_dialog_low_oil); myDialog.setCancelable(true);/*from www .j ava 2 s . c o m*/ myDialog.setTitle("Peringatan!"); Button batal = (Button) myDialog.findViewById(R.id.dialog_low_oil_cancel); Button cari = (Button) myDialog.findViewById(R.id.dialog_low_oil_cari); myDialog.show(); cari.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(MainActivity.this, MainCari.class); startActivity(i); } }); batal.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.cancel(); } }); }
From source file:net.evendanan.android.hagarfingerpainting.HagarFingerpaintingActivity.java
@Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DIALOG_NEW_PAPER: EditText painterName = (EditText) dialog.findViewById(R.id.painter_name_input_text); painterName.setText(getPainterName()); //recreating the items (so they lose their inner state) final Gallery colors = (Gallery) dialog.findViewById(R.id.colors_list); ((PaperColorListAdapter) colors.getAdapter()).clearItemsState(); break;//ww w . j a va 2 s . com default: super.onPrepareDialog(id, dialog); break; } }
From source file:com.mEmoZz.qrgen.MainActivity.java
public void mCore() { Toast.makeText(getApplicationContext(), "Generating code...", Toast.LENGTH_SHORT).show(); new CountDownTimer(3000, 1000) { public void onTick(long millisUntilFinished) { }/*from w ww. j a v a 2 s . com*/ public void onFinish() { Button yupBtn, delBtn, shareBtn; Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show(); final Dialog dialog = new Dialog(MainActivity.this); dialog.setContentView(R.layout.dialog); dialog.setTitle("Want to save?"); iv = (ImageView) dialog.findViewById(R.id.iv); iv.setImageBitmap(bm); shareBtn = (Button) dialog.findViewById(R.id.shareBtn); shareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { shareIt(); } }); yupBtn = (Button) dialog.findViewById(R.id.btn1); yupBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mStream(); dialog.dismiss(); } }); delBtn = (Button) dialog.findViewById(R.id.btn2); delBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Toast.makeText(getApplicationContext(), "Deleted!", Toast.LENGTH_SHORT).show(); } }); dialog.show(); dialog.setCancelable(false); keepDialog(dialog); } }.start(); }
From source file:transapps.gpxfitness.ui.MainActivity.java
public void editProfileAlertDialog() { if (!ProfileAccessor.isProfileSet()) { profileAlertDialog();/*w w w . ja va 2s.c o m*/ return; } final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.profile_dialog); dialog.setTitle("Edit Profile:"); dialog.setCancelable(true); Button ok_button = (Button) dialog.findViewById(R.id.button); ok_button.setText("Ok"); final EditText username = (EditText) dialog.findViewById(R.id.username); username.setText(ProfileAccessor.getUsername()); final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft); height_ft.setText("" + (int) ProfileAccessor.getHeight() / 12); final EditText height_in = (EditText) dialog.findViewById(R.id.height_in); height_in.setText("" + (int) ProfileAccessor.getHeight() % 12); final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs); weight_lbs.setText(ProfileAccessor.getWeight() + ""); final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs); age_yrs.setText(ProfileAccessor.getAge() + ""); final RadioButton male = (RadioButton) dialog.findViewById(R.id.male); final RadioButton female = (RadioButton) dialog.findViewById(R.id.female); if (ProfileAccessor.getSex().equals("male")) { male.setChecked(true); female.setChecked(false); } else { male.setChecked(false); female.setChecked(true); } final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs }; ok_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String user_string = username.getText().toString(); String height_ft_string = height_ft.getText().toString(); String height_in_string = height_in.getText().toString(); Log.d("TEXT", height_in_string); String weight_lbs_string = weight_lbs.getText().toString(); String age_yrs_string = age_yrs.getText().toString(); boolean are_any_empty = false; for (EditText e : et) { String str = e.getText().toString(); if (str == null || str.length() == 0) are_any_empty = true; } if (!are_any_empty) { int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string); String sex; if (male.isChecked()) sex = "male"; else sex = "female"; //ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex, Integer.parseInt(age_yrs_string)); ProfileAccessor.changeUsername(user_string); //actionBar.setTitle(getString(R.string.app_name) + ": " + ProfileAccessor.getUsername()); ProfileAccessor.changeHeight(height); ProfileAccessor.changeWeight(Double.parseDouble(weight_lbs_string)); ProfileAccessor.changeSex(sex); ProfileAccessor.changeAge(Integer.parseInt(age_yrs_string)); dialog.dismiss(); } } }); dialog.show(); }
From source file:com.qubittech.feelknit.app.MainActivity.java
@Override protected void onNavItemSelected(int id) { switch (id) { case 101:/* www . j av a2s. c o m*/ ShowProfileFragment(ApplicationHelper.getAvatar(getApplicationContext())); break; case 102: ShowCurrentFeelingsFragment(); break; case 103: StartUserFeelingsFragment(); break; case 104: showCommentsFeelingsFragment(); break; case 105: ShowRelatedFeelingFragment(); break; case 106: final Dialog d = new Dialog(this, R.style.CustomDialogTheme); d.setContentView(R.layout.custom_dialog); d.show(); TextView version = (TextView) d.findViewById(R.id.versionTextView); TextView saripaar = (TextView) d.findViewById(R.id.saripaar); TextView licenseLink = (TextView) d.findViewById(R.id.licenseLink); final TextView license = (TextView) d.findViewById(R.id.license); saripaar.setText(Html.fromHtml("<u>android-saripaar</u>")); licenseLink.setText(Html.fromHtml("(<u>license</u>)")); saripaar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uriUrl = Uri.parse("https://github.com/ragunathjawahar/android-saripaar"); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); startActivity(launchBrowser); } }); license.setText("Copyright 2012 - 2015 Mobs and Geeks\n\n" + "Licensed under the Apache License, Version 2.0 (the \"License\");\n" + "you may not use this file except in compliance with the License.\n" + "You may obtain a copy of the License at\n" + "\n" + " http://www.apache.org/licenses/LICENSE-2.0\n" + "\n" + "Unless required by applicable law or agreed to in writing, software\n" + "distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "See the License for the specific language governing permissions and\n" + "limitations under the License."); licenseLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { license.setVisibility(license.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE); } }); try { version.setText(getApplicationContext().getPackageManager() .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } TextView close_btn = (TextView) d.findViewById(R.id.okButton); close_btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { d.dismiss(); } }); } }
From source file:com.example.dany.jjdraw.MainActivity.java
@Override public void onClick(View view) { if (view.getId() == R.id.draw_btn) { final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Brush size"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener(new OnClickListener() { @Override/*from w w w .jav a 2 s . co m*/ public void onClick(View v) { drawView.setBrushSize(smallBrush); drawView.setLastBrushSize(smallBrush); drawView.setErase(false); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(mediumBrush); drawView.setLastBrushSize(mediumBrush); drawView.setErase(false); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(largeBrush); drawView.setLastBrushSize(largeBrush); drawView.setErase(false); brushDialog.dismiss(); } }); brushDialog.show(); } else if (view.getId() == R.id.erase_btn) { //switch to erase - choose size final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Eraser size"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setErase(true); drawView.setBrushSize(smallBrush); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setErase(true); drawView.setBrushSize(mediumBrush); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { drawView.setErase(true); drawView.setBrushSize(largeBrush); brushDialog.dismiss(); } }); brushDialog.show(); } else if (view.getId() == R.id.new_btn) { //new button AlertDialog.Builder newDialog = new AlertDialog.Builder(this); newDialog.setTitle("New drawing"); newDialog.setMessage("Start new drawing (you will lose the current drawing)?"); newDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { drawView.startNew(null); dialog.dismiss(); } }); newDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); newDialog.show(); } else if (view.getId() == R.id.save_btn) { //save drawing AlertDialog.Builder saveDialog = new AlertDialog.Builder(this); saveDialog.setTitle("Save drawing"); saveDialog.setMessage("Save drawing to device Gallery?"); saveDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //save drawing drawView.setDrawingCacheEnabled(true); String imgSaved = MediaStore.Images.Media.insertImage(MainActivity.this.getContentResolver(), drawView.getDrawingCache(), UUID.randomUUID().toString() + ".png", "drawing"); if (imgSaved != null) { Toast savedToast = Toast.makeText(getApplicationContext(), "Drawing saved to Gallery!", Toast.LENGTH_SHORT); savedToast.show(); } else { for (int i = 0; i < 3; i++) { // tried to increase the duration Toast unsavedToast = Toast.makeText(getApplicationContext(), "Oops! Image could not be saved. " + "Explicit write permission to storage device may required." + "Check Settings->" + "Application Manager->" + "JJDraw->" + "Permissions.", Toast.LENGTH_LONG); unsavedToast.show(); } } drawView.destroyDrawingCache(); } }); saveDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); saveDialog.show(); } }
From source file:com.medisa.myspacecal.Range.java
@Override public void onSideNavigationItemClick(int itemId) { switch (itemId) { case R.id.side_navigation_menu_calendario: range = 0;// w ww . ja va 2 s.co m Intent i = new Intent(this, MainActivity.class); startActivity(i); break; case R.id.side_navigation_menu_date_range: // custom dialog final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.custom_range_date); dialog.setTitle("Data range"); // set the custom dialog components - text, image and button final DatePicker dpStart = (DatePicker) dialog.findViewById(R.id.dpStart); final DatePicker dpEnd = (DatePicker) dialog.findViewById(R.id.dpEnd); Button btnSalva = (Button) dialog.findViewById(R.id.btnSalva); final CheckBox cbIntegralBox = (CheckBox) dialog.findViewById(R.id.cbIntegral); // if button is clicked, close the custom dialog btnSalva.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dateStart = Funzioni.addZero(dpStart.getDayOfMonth(), 2) + "-" + Funzioni.addZero(dpStart.getMonth(), 2) + "-" + dpStart.getYear(); dateEnd = Funzioni.addZero(dpEnd.getDayOfMonth(), 2) + "-" + Funzioni.addZero(dpEnd.getMonth(), 2) + "-" + dpEnd.getYear(); Log.e(dateStart, dateEnd); if (cbIntegralBox.isChecked()) { //#########################JSON AsyncHttpClient client = new AsyncHttpClient(); client.get("http://199.180.196.10/json/integral?startdate=" + dateStart + "&enddate=" + dateEnd, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { Log.e("SCARICATO", response); JSONArray jObject; try { jObject = new JSONArray(response); for (int i = 0; i < jObject.length(); i++) { JSONArray menuObject = jObject.getJSONArray(i); String dataStart = menuObject.getString(0); String dataEnd = menuObject.getString(1); String raj2000 = menuObject.getString(2); String decj2000 = menuObject.getString(3); String target = menuObject.getString(4); Log.e("", dataStart + " " + dataEnd + " " + raj2000 + " " + decj2000 + " " + target); satellitiIntegral.add(new SatelliteIntegral(dataStart, dataEnd, raj2000, decj2000, target)); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } dialog.dismiss(); // Intent mioIntent= new Intent(ctx, Range.class); // startActivity(mioIntent); } }); dialog.show(); break; // case R.id.side_navigation_menu_item3: // invokeActivity(getString(R.string.title3), R.drawable.ic_android3); // break; // // case R.id.side_navigation_menu_item4: // invokeActivity(getString(R.string.title4), R.drawable.ic_android4); // break; // // case R.id.side_navigation_menu_item5: // invokeActivity(getString(R.string.title5), R.drawable.ic_android5); // break; default: return; } }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Utility method to display an alert dialog. Use instead of AlertDialog to * get the right styling.//from ww w . j a v a 2 s .c o m * * @param context * @param message */ public static void displayAlert(final Launcher context, String message) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.alert); final TextView alertTextView = (TextView) dialog.findViewById(R.id.alertText); alertTextView.setText(message); Button alertButton = (Button) dialog.findViewById(R.id.alertButton); alertButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { context.showCover(false); dialog.dismiss(); } }); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); }
From source file:com.konsula.app.gcm.MyGcmListenerService.java
private void handleGCM(Bundle bundle) { try {/*from w w w .j av a2s . co m*/ Bundle data = bundle; String message = data.getString(TAG_MESSAGE, ""); final String doc_name = data.getString(TAG_DOC_NAME, ""); final String schedule = data.getString(TAG_SCHEDULE, ""); final String specialization = data.getString(TAG_SPECIALIZATION, ""); final String status = data.getString(TAG_STATUS, ""); String tele_uuid = data.getString(TAG_TELE_UUID, ""); String page = data.getString(TAG_PAGE, ""); String type = data.getString(TAG_TYPE, ""); if (type.equals("dialog")) { if (page.equals("teledoc-confirmed")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_confirm, null); TextView textViewname = (TextView) invoiceDetail.findViewById(R.id.tvNamaDokter); TextView textViewspeciality = (TextView) invoiceDetail.findViewById(R.id.etSpeciality); TextView textViewdate = (TextView) invoiceDetail.findViewById(R.id.tvDate); TextView textViewstatus = (TextView) invoiceDetail.findViewById(R.id.text_status); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textViewname.setText(doc_name); textViewspeciality.setText(specialization); textViewdate.setText(schedule); textViewstatus.setText(status.toUpperCase()); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } if (page.equals("teledoc-cancel")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm, null); TextView textView = (TextView) invoiceDetail.findViewById(R.id.message); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textView.setText(getResources().getString(R.string.text_teledoc_cancel)); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } if (page.equals("teledoc-reschedule")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm, null); TextView textView = (TextView) invoiceDetail.findViewById(R.id.message); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textView.setText(getResources().getString(R.string.text_reschedule_information)); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } } else if (type.equals("intent") && (page.equals("teledoc-confirmation-reschedule"))) { Intent intent = new Intent(this, TeledocRescheduleActivity.class); intent.putExtra(TeledocRescheduleActivity.TAG_TELE_UUID, tele_uuid); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_NAME, doc_name); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SPECIALIZATION, specialization); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SCHEDULE, schedule); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } catch (Exception e) { Log.e("ee", e.getMessage()); Log.e("ee", String.valueOf(e)); } }