android.webkit.WebView.loadData()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(259)

本文整理了Java中android.webkit.WebView.loadData()方法的一些代码示例,展示了WebView.loadData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.loadData()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:loadData

WebView.loadData介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

WebView webView = (WebView) findViewById(R.id.DemoWebView);
WebSettings webSettings = webView.getSettings();
webSettings.setDefaultTextEncodingName("utf-8");  
webView.loadData(scandinavianCharacters, "text/html; charset=utf-8", null);

代码示例来源:origin: stackoverflow.com

WebView mWebView = (WebView) findViewById(R.id.myWebView);
WebSettings settings = mWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");                   
mWebView.loadData(myCharacters, "text/html; charset=utf-8",null);

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: 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");
}   
}

代码示例来源:origin: commonsguy/cw-omnibus

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);
}

代码示例来源:origin: Justson/AgentWeb

@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);
}

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: commonsguy/cw-omnibus

@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);
 }
}

代码示例来源:origin: androidquery/androidquery

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);
  
}

代码示例来源:origin: PrivacyApps/html-textview

@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");
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

@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();
}

代码示例来源:origin: ankidroid/Anki-Android

@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();
    }
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

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);
}

代码示例来源:origin: robolectric/robolectric

@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");
}

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: stackoverflow.com

@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");
}

代码示例来源:origin: stackoverflow.com

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");

代码示例来源:origin: TheFinestArtist/FinestWebView-Android

webView.loadData(data, mimeType, encoding);
} else if (url != null) {
 webView.loadUrl(url);

代码示例来源:origin: selendroid/selendroid

@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");
}

相关文章

WebView类方法