2
如何通過webview顯示單個元素?Android:帶有單個元素的webview
這是我的代碼:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
wv.getSettings().setPluginState(PluginState.ON);
wv.getSettings().setAllowFileAccess(true);
wv.loadUrl("http://exampleurl.com/");
wv.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
StringBuilder builder = new StringBuilder("");
builder.append("javascript:document.getElementById('header').style.visibility= 'hidden';");
builder.append("javascript:document.getElementsByClassName('pile');");
view.loadUrl(builder.toString());
}
});
}
這是一個形象的例子來我的問題:
順祝商祺!