首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android 用源打开网页

2012-09-09 
android 用流打开网页public class Test extends Activity {@Overridepublic void onCreate(Bundle savedI

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

热点排行