当前位置: 代码迷 >> Android >> android 用源打开网页
  详细解决方案

android 用源打开网页

热度:105   发布时间:2016-05-01 15:39:34.0
android 用流打开网页

public class Test extends Activity {
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
setContentView(webview);
try {
InputStream fin = getAssets().open(“index.html”);
byte[] buffer = new byte[fin.available()]; fin.read(buffer);
fin.close();
webview.loadData(new String(buffer), “text/html”, “UTF-8″); }
catch (IOException e) { e.printStackTrace(); }
}
}

  相关解决方案