WebView webView = (WebView) findViewById(R.id.DemoWebView); WebSettings webSettings = webView.getSettings(); webSettings.setDefaultTextEncodingName("utf-8"); webView.loadData(scandinavianCharacters, "text/html; charset=utf-8", null);
WebView mWebView = (WebView) findViewById(R.id.myWebView); WebSettings settings = mWebView.getSettings(); settings.setDefaultTextEncodingName("utf-8"); mWebView.loadData(myCharacters, "text/html; charset=utf-8",null);
WebView webView = (WebView)findViewById(R.id.webView); //you can load an html code webView.loadData("yourCode Html to load on the webView " , "text/html" , "utf-8"); // you can load an URL webView.loadUrl("http://www.stackoverflow.com");
public class ContentViewActivity extends Activity { WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.content); webView = (WebView) findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); String displayString = getIntent().getExtras().getString("display"); if(displayString != null) webView.loadData(displayString, "text/html", "utf-8"); } }
void loadTime() { String page= "<html><body><a href=\"http://webview.used.to.be.less.annoying/clock\">" + DateUtils.formatDateTime(this, new Date().getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME) + "</a></body></html>"; browser.loadData(page, "text/html; charset=UTF-8", null); }
@Override public void loadData(final String data, final String mimeType, final String encoding) { if (!AgentWebUtils.isUIThread()) { mHandler.post(new Runnable() { @Override public void run() { loadData(data, mimeType, encoding); } }); return; } this.mWebView.loadData(data, mimeType, encoding); }
setContentView(R.layout.main); WebView view = new WebView(this); view.setVerticalScrollBarEnabled(false); ((LinearLayout)findViewById(R.id.inset_web_view)).addView(view); view.loadData(getString(R.string.hello), "text/html; charset=utf-8", "utf-8");
@Override public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main); browser=findViewById(R.id.webkit); browser.loadData("<html><body>Hello, world!</body></html>", "text/html; charset=UTF-8", null); } }
private void delaySetup(){ wv.setPictureListener(new PictureListener() { @Override public void onNewPicture(WebView view, Picture picture) { wv.setPictureListener(null); setup(); } }); //wv.setInitialScale(100); wv.loadData("<html></html>", "text/html", "utf-8"); wv.setBackgroundColor(color); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); String tableHtml = getIntent().getStringExtra(EXTRA_TABLE_HTML); WebView webView = (WebView) findViewById(R.id.web_view); webView.loadData(tableHtml, "text/html", "UTF-8"); } }
@Override protected void onPostExecute(Integer result) { Activity activity = getActivity(); if (activity == null) { return; } String webViewData = getFormattedLicense(activity, license); AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setTitle(license.getName()); WebView wv = new WebView(activity); wv.loadData(webViewData, "text/html; charset=UTF-8", null); alert.setView(wv); alert.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); }
@Override protected void onPostExecute(String html) { if (html != null && mIsRunning) { try { mWebView.loadData(URLEncoder.encode(html, "UTF-8").replaceAll("\\+", " "), "text/html; charset=utf-8", "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } mProgressBar.setVisibility(View.GONE); int backgroundColor = Themes.getColorFromAttr(mWebView.getContext(), android.R.attr.colorBackground); mWebView.setBackgroundColor(backgroundColor); mWebView.setVisibility(View.VISIBLE); mWebView.invalidate(); } } }
private void printReport() { Template tmpl= Mustache.compiler().compile(getString(R.string.report_body)); WebView print=prepPrintWebView(getString(R.string.tps_report)); print.loadData(tmpl.execute(new TpsReportContext(prose.getText() .toString())), "text/html; charset=UTF-8", null); }
@Test public void shouldRecordLastLoadedData() { webView.loadData("<html><body><h1>Hi</h1></body></html>", "text/html", "utf-8"); ShadowWebView.LoadData lastLoadData = shadowOf(webView).getLastLoadData(); assertThat(lastLoadData.data).isEqualTo("<html><body><h1>Hi</h1></body></html>"); assertThat(lastLoadData.mimeType).isEqualTo("text/html"); assertThat(lastLoadData.encoding).isEqualTo("utf-8"); }
String content = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+ "<html><head>"+ "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+ "<head><body>"; content += myContent + "</body></html>"; WebView WebView1 = (WebView) findViewById(R.id.webView1); WebView1.loadData(content, "text/html; charset=utf-8", "UTF-8");
final WebView page = (WebView) findViewById(R.id.webview); String text = "<html><head>" + "<style type=\"text/css\">body{color: #ffdec2; background-color: #1F0C01;}" + "</style></head>" + "<body>" + "<p align=\"justify\">" + getString(R.string.intro_content) + "</p> " + "</body></html>"; page.loadData(text, "text/html", "utf-8");
@Override protected void onDestroy() { super.onDestroy(); final WebView webview = (WebView)findViewById(R.id.webPlayer); // Calling .clearView does not stop the flash player must load new data webview.loadData("", "text/html", "utf-8"); }
WebView view = (WebView) findViewById(R.id.textContent); String text; text = "<html><body><p align=\"justify\">"; text+= "This is the text will be justified when displayed!!!"; text+= "</p></body></html>"; view.loadData(text, "text/html", "utf-8");
webView.loadData(data, mimeType, encoding); } else if (url != null) { webView.loadUrl(url);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); WebView webview = (WebView) findViewById(R.id.webview); WebSettings settings = webview.getSettings(); // viewport meta tag support settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); webview.setWebViewClient(new AndroidDriverClient()); webview.loadData("<html><body><h1 id='AndroidDriver'>Android driver webview app</h1>" + "</body></html>", "text/html", "UTF-8"); }