protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
Bundle bundle = this.getIntent().getExtras();
WebView detailsLink=(WebView)findViewById(R.id.web_view);
detailsLink.getSettings().setJavaScriptEnabled(true);
detailsLink.loadUrl(bundle.getString("keyLink"));
}
这会在android webview字段中显示整个html页面,但我必须在我的Web视图中显示正文部分。我尝试了查询,但它无法正常工作。
String detailsLink1="<html><body><iframe src='keyLink' width='100%' height='100' scrolling='no'> </iframe></body></html>";
detailsLink.loadData(detailsLink1, "text/html", "utf-8");
这不起作用。
答案 0 :(得分:0)
这样做:
URL url = new URL("your url");
InputStream is = url.openStream();
byte[] b = new Byte[size of data you want to read];
String s = new String(b);
现在可以随意存储或显示此字符串。