List of usage examples for android.app AlertDialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:truesculpt.ui.panels.WebFilePanel.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getManagers().getUtilsManager().updateFullscreenWindowStatus(getWindow()); setContentView(R.layout.webfile);/*from w w w.j a v a 2 s.c o m*/ getManagers().getUsageStatisticsManager().TrackEvent("OpenFromWeb", "", 1); mWebView = (WebView) findViewById(R.id.webview); mWebView.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new JavaScriptInterface(this, getManagers()), "Android"); int nVersionCode = getManagers().getUpdateManager().getCurrentVersionCode(); mWebView.loadUrl(mStrBaseWebSite + "?version=" + nVersionCode); mPublishToWebBtn = (Button) findViewById(R.id.publish_to_web); mPublishToWebBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String name = getManagers().getMeshManager().getName(); final File imagefile = new File(getManagers().getFileManager().GetImageFileName()); final File objectfile = new File(getManagers().getFileManager().GetObjectFileName()); getManagers().getUsageStatisticsManager().TrackEvent("PublishToWeb", name, 1); if (imagefile.exists() && objectfile.exists()) { try { final File zippedObject = File.createTempFile("object", "zip"); zippedObject.deleteOnExit(); BufferedReader in = new BufferedReader(new FileReader(objectfile)); BufferedOutputStream out = new BufferedOutputStream( new GZIPOutputStream(new FileOutputStream(zippedObject))); System.out.println("Compressing file"); int c; while ((c = in.read()) != -1) { out.write(c); } in.close(); out.close(); long size = 0; size = new FileInputStream(imagefile).getChannel().size(); size += new FileInputStream(zippedObject).getChannel().size(); size /= 1000; final SpannableString msg = new SpannableString( "You will upload your latest saved version of this scupture representing " + size + " ko of data\n\n" + "When clicking the yes button you accept to publish your sculpture under the terms of the creative commons share alike, non commercial license\n" + "http://creativecommons.org/licenses/by-nc-sa/3.0" + "\n\nDo you want to proceed ?"); Linkify.addLinks(msg, Linkify.ALL); AlertDialog.Builder builder = new AlertDialog.Builder(WebFilePanel.this); builder.setMessage(msg).setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { PublishPicture(imagefile, zippedObject, name); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); AlertDialog dlg = builder.create(); dlg.show(); // Make the textview clickable. Must be called after // show() ((TextView) dlg.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } catch (Exception e) { e.printStackTrace(); } } else { AlertDialog.Builder builder = new AlertDialog.Builder(WebFilePanel.this); builder.setMessage( "File has not been saved, you need to save it before publishing\nDo you want to proceed to save window ?") .setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { ((FileSelectorPanel) getParent()).getTabHost().setCurrentTab(2); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); builder.show(); } } }); }
From source file:org.steveleach.scoresheet.ui.ScoresheetActivity.java
private View getDialogView(AlertDialog dialog, String resourceName) { int textViewId = dialog.getContext().getResources().getIdentifier(resourceName, null, null); return dialog.findViewById(textViewId); }
From source file:org.rm3l.ddwrt.tiles.DDWRTTile.java
@Override public final void onClick(View view) { final OnClickIntent onClickIntentAndListener = getOnclickIntent(); final Intent onClickIntent; if (onClickIntentAndListener != null && (onClickIntent = onClickIntentAndListener.getIntent()) != null) { final String dialogMsg = onClickIntentAndListener.getDialogMessage(); //noinspection ConstantConditions final AlertDialog alertDialog = Utils.buildAlertDialog(mParentFragmentActivity, null, Strings.isNullOrEmpty(dialogMsg) ? "Loading detailed view..." : dialogMsg, false, false); alertDialog.show();//from ww w . j a v a 2 s . c o m ((TextView) alertDialog.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_HORIZONTAL); new Handler().postDelayed(new Runnable() { @Override public void run() { ((DDWRTBaseFragment) mParentFragment).startActivityForResult(onClickIntent, onClickIntentAndListener.getListener()); alertDialog.cancel(); } }, 2500); } }
From source file:ch.ethz.coss.nervousnet.hub.ui.SensorDisplayActivity.java
public void showInfo(View view) { String title = "Sensor Frequency:"; // Includes the updates as well so users know what changed. String message = "\n\n- Settings to control the frequency of Sensors." + "\nClick on the options to switch off or change the frequency." + "\n- Various levels of frequency can be selected" + "\n - HIGH, MEDIUM, LOW or OFF" + "\n Please note if the Nervousnet Service is Paused, this control is disabled."; AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(title).setMessage(message) .setPositiveButton("OK", new Dialog.OnClickListener() { @Override//from ww w.jav a2 s. c om public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setCancelable(false); AlertDialog alert = builder.create(); alert.show(); alert.getWindow().getAttributes(); TextView textView = (TextView) alert.findViewById(android.R.id.message); textView.setTextSize(12); }
From source file:github.daneren2005.dsub.util.Util.java
private static void showDialog(Context context, int icon, String title, String message) { SpannableString ss = new SpannableString(message); Linkify.addLinks(ss, Linkify.ALL);// w w w.j av a2 s . c o m AlertDialog dialog = new AlertDialog.Builder(context).setIcon(icon).setTitle(title).setMessage(ss) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { dialog.dismiss(); } }).show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.easyrpg.player.player.EasyRpgPlayerActivity.java
private void reportBug() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.app_name); final SpannableString bug_msg = new SpannableString( getApplicationContext().getString(R.string.report_bug_msg)); Linkify.addLinks(bug_msg, Linkify.ALL); // set dialog message alertDialogBuilder.setMessage(bug_msg).setCancelable(false) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ArrayList<Uri> files = new ArrayList<Uri>(); String savepath = getIntent().getStringExtra(TAG_SAVE_PATH); files.add(Uri.fromFile(new File(savepath + "/easyrpg_log.txt"))); for (File f : GameBrowserHelper.getSavegames(new File(savepath))) { files.add(Uri.fromFile(f)); }/*from w w w. j a va2 s. c o m*/ if (Build.VERSION.SDK_INT >= 24) { // Lazy workaround as suggested on https://stackoverflow.com/q/38200282 try { Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure"); m.invoke(null); } catch (Exception e) { Log.i("EasyRPG", "Bug report: Calling disableDeathOnFileUriExposure failed"); } } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setData(Uri.parse("mailto:")); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "easyrpg@easyrpg.org" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Bug report"); intent.putExtra(Intent.EXTRA_TEXT, getApplicationContext().getString(R.string.report_bug_mail)); intent.putExtra(Intent.EXTRA_STREAM, files); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java
private Dialog onCreatePasswdDialog() { final AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setPositiveButton(R.string.ok, new OnClickListener() { @Override//from w w w . ja v a2 s .c om public void onClick(DialogInterface dialog, int which) { if (dialog instanceof AlertDialog) { final AlertDialog dlg = (AlertDialog) dialog; final EditText passwd = (EditText) dlg.findViewById(R.id.dialog_text); if (passwd == null) { return; } mPasswd = passwd.getText().toString(); updateMessage(R.string.login_google, null); new Thread(new Runnable() { public void run() { login(); } }).start(); } } }); ab.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); ab.setTitle("Password for " + mAccount.name); final LayoutInflater inflator = getLayoutInflater(); ab.setView(inflator.inflate(R.layout.passwd, null)); return ab.create(); }
From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java
private void showResultDialog(final String res) { final AlertDialog d = new AlertDialog.Builder(this).create(); d.show();//w ww . j a v a2 s. c o m d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle")); d.setCanceledOnTouchOutside(false); TextView tv_content = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content")); String content = getResources().getString(BaseUtils.getResourceValue("string", TextUtils.isEmpty(res) ? "oasisgames_sdk_epin_notice_3" : "oasisgames_sdk_epin_notice_4")); content = content.replace("DIAMOND", res); tv_content.setText(content); TextView tv_sure = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure")); tv_sure.setText( getResources().getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_common_btn_sure"))); tv_sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (!TextUtils.isEmpty(res)) et_code.setText(""); d.dismiss(); } }); TextView tv_cancle = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle")); tv_cancle.setVisibility(View.GONE); TextView tv_text = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_text")); tv_text.setVisibility(View.GONE); }
From source file:org.rssin.android.NavigationDrawerFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }// w w w .j a v a 2 s .co m if (item.getItemId() == R.id.action_settings) { getCurrentItem().invokeActionSettings(mDrawerLayout.getContext()); return true; } if (item.getItemId() == R.id.action_info) { TextView message = new TextView(getActivity()); message.setText(Html.fromHtml(getString(R.string.app_info))); int padding = getResources().getDimensionPixelSize(R.dimen.listview_item_padding); message.setPadding(padding, padding, padding, 0); message.setMovementMethod(LinkMovementMethod.getInstance()); AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.app_name)) .setView(message).setPositiveButton(R.string.button_ok, null).setIcon(R.mipmap.ic_launcher) .show(); View titleDivider = dialog.findViewById(getResources().getIdentifier("titleDivider", "id", "android")); if (titleDivider != null) { titleDivider.setBackgroundColor(getResources().getColor(R.color.abc_primary_text_material_light)); } TextView title = (TextView) dialog .findViewById(getResources().getIdentifier("alertTitle", "id", "android")); if (title != null) { title.setTextColor(getResources().getColor(R.color.abc_primary_text_material_light)); } } return super.onOptionsItemSelected(item); }
From source file:com.pepperonas.showcase.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals("About")) { new MaterialDialog.Builder(this).title("MaterialDialog library").customView(R.layout.dialog_lib_info) .positiveText("OK").positiveColor(R.color.grey_700).icon(R.drawable.ic_launcher) .showListener(new MaterialDialog.ShowListener() { @Override/*from www .j a v a 2 s. c om*/ public void onShow(AlertDialog d) { super.onShow(d); TextView tvLibInfo = (TextView) d.findViewById(R.id.tv_lib_info); tvLibInfo.setText(Html.fromHtml(getString(R.string.web_presentation_info))); tvLibInfo.setMovementMethod(LinkMovementMethod.getInstance()); } }).show(); } else if (item.getTitle().equals(Const.HIDE_TOASTS)) { mSharedPreferences.edit().putBoolean("SHOW_TOASTS", false).apply(); item.setTitle(Const.SHOW_TOASTS); } else if (item.getTitle().equals(Const.SHOW_TOASTS)) { mSharedPreferences.edit().putBoolean("SHOW_TOASTS", true).apply(); item.setTitle(Const.HIDE_TOASTS); } return super.onOptionsItemSelected(item); }