List of usage examples for android.webkit WebView WebView
public WebView(Context context)
From source file:com.golfmarin.golf.WebViewFragment.java
/** * Called to instantiate the view. Creates and returns the WebView. *///w ww .j ava 2 s. c om @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mWebView != null) { mWebView.destroy(); } mWebView = new WebView(getActivity()); mIsWebViewAvailable = true; /* Weather parser = new Weather(); String localWeather = parser.getWeather(); Log.v("myApp", "WebViewFragment, onCreateView, localWeather: " + localWeather); // mWebView.loadUrl("http://weather.yahooapis.com/forecastrss?w=12797462"); mWebView.loadData(localWeather, "text/html", null); */ return mWebView; }
From source file:de.eidottermihi.rpicheck.fragment.QueryErrorMessagesDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { List<String> messages = this.getArguments().getStringArrayList(KEY_ERROR_MESSAGES); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.errormessages_dialog_title); WebView wv = new WebView(getActivity()); wv.loadDataWithBaseURL(null, this.createErrorMessages(messages), "text/html", "UTF-8", null); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { Compability.setViewLayerTypeSoftware(wv); }/*w w w . j a v a2 s . co m*/ wv.setBackgroundColor(0); builder.setView(wv); builder.setCancelable(false); builder.setPositiveButton("Ok", null); builder.setIcon(android.R.drawable.ic_dialog_info); return builder.create(); }
From source file:com.swiftkaydevelopment.fullsailcommunicate.fragments.AssignmentViewFragment.java
@Nullable @Override/* w w w . j a v a 2s. c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mWebView = new WebView(getActivity()); CookieSyncManager.createInstance(getActivity()); CookieSyncManager.getInstance().startSync(); mWebView.getSettings().supportZoom(); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadUrl("https://course.fso.fullsail.edu/class_sections/66645/assignments/1047897"); return mWebView; }
From source file:com.taobao.luaview.view.LVWebView.java
private void init(Context context) { this.mWebView = new WebView(context); this.addView(this.mWebView, LuaViewUtil.createRelativeLayoutParamsMM()); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.getSettings().setSavePassword(false); this.setOnRefreshListener(new OnRefreshListener() { @Override/*w w w . ja va 2s . c om*/ public void onRefresh() { mWebView.reload(); } }); this.setEnabled(false); // setupDefaultWebViewClient(); }
From source file:com.moto.miletus.application.utils.LicenseDialog.java
@NonNull @Override/*from w w w . j ava 2s.c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final WebView webView = new WebView(getActivity()); webView.loadUrl("file:///android_asset/licenses.html"); return new AlertDialog.Builder(getActivity()).setView(webView) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.iangclifton.auid.appendixc.sections.LoadingIndicatorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mWebView = new WebView(inflater.getContext()); mWebView.setWebChromeClient(new WebChromeClient() { @Override//www. j av a 2 s . c o m public void onProgressChanged(WebView view, int progress) { getActivity().setProgress(progress * 100); } }); return mWebView; }
From source file:com.nineducks.hereader.ui.ItemDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d("hereader", "entering ItemDetailsFragment.onCreateView"); if (container == null) { Log.d("hereader", "leaving ItemDetailsFragment.onCreateView"); return null; }//w w w .ja va 2 s . com String url = getArguments().getString("url"); WebView webView = new WebView(getActivity().getApplicationContext()); webView.loadUrl(url); Log.d("hereader", "leaving ItemDetailsFragment.onCreateView"); return webView; }
From source file:com.giovanniterlingen.windesheim.controllers.WebViewController.java
public WebView createWebView() { WebView webView = new WebView(activity); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setSupportZoom(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { int lastSlash = url.lastIndexOf('/'); String fileName = url.substring(lastSlash + 1); DownloadManager downloadManager = (DownloadManager) activity .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.addRequestHeader("Cookie", new CookieController().getNatSchoolCookie()).setTitle(fileName) .setDescription(activity.getResources().getString(R.string.downloading)) .setDestinationInExternalPublicDir(File.separator + ApplicationLoader.applicationContext.getResources().getString(R.string.app_name), fileName)/*from ww w. j av a2s . c om*/ .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); downloadManager.enqueue(request); } }); return webView; }
From source file:net.naonedbus.utils.InfoDialogUtils.java
/** * Afficher une dialog avec un contenu au format HTML * //from w w w . jav a2s . c om * @param context * @param html */ public static void showHtml(final Context context, final String html) { AlertDialog.Builder moreDetailsDialog = null; final WebView webView = new WebView(context); final ScrollView scrollView = new ScrollView(context); webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); webView.setBackgroundColor(Color.WHITE); webView.loadDataWithBaseURL("fake://not/needed", html, "text/html", "UTF-8", null); // Encoding // fix // for // Android // 3.x // / // 4.x scrollView.addView(webView); moreDetailsDialog = new AlertDialog.Builder(context); moreDetailsDialog.setIcon(android.R.drawable.ic_dialog_info); moreDetailsDialog.setTitle("Informations"); moreDetailsDialog.setView(scrollView); moreDetailsDialog.setPositiveButton(android.R.string.ok, null); moreDetailsDialog.show(); }
From source file:com.bluekai.sdk.BlueKaiViewDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); if (blueKaiView == null) { blueKaiView = new WebView(getActivity()); WebViewClient client = new WebViewClient() { @Override// ww w . ja v a2 s . co m public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); Logger.debug("BlueKaiView", "Error loading BK URL in webview -- " + errorCode + " -- " + description); errorOccured = true; if (listener != null) { listener.onViewLoaded(false, isExistingData(), getParamsList()); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (!errorOccured && listener != null) { errorOccured = false; listener.onViewLoaded(true, isExistingData(), getParamsList()); } } }; blueKaiView.setWebViewClient(client); WebSettings webSettings = blueKaiView.getSettings(); webSettings.setJavaScriptEnabled(true); int height = 1, width = 1; // if (devMode) { height = width = 300; // } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.setMargins(10, 10, 10, 10); blueKaiView.setLayoutParams(params); blueKaiView.setBackgroundColor(Color.LTGRAY); alertDialogBuilder.setNegativeButton("Close", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } blueKaiView.loadUrl(url); alertDialogBuilder.setView(blueKaiView); return alertDialogBuilder.create(); }