【发布时间】:2012-09-08 17:22:35
【问题描述】:
我想从网络上获取 html,但我不能。这是我的代码
final EditText et = (EditText) findViewById(R.id.editText1);
final TextView tv = (TextView) findViewById(R.id.textView1);
final Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
URL url = null;
url = new URL(et.getText().toString());
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
tv.append(line);
}
} catch (Exception e) {
Log.e("error", "erorr connection "+ e.toString());
}
}
});
我还添加了来自互联网的许可。目标版本 4.0.3
【问题讨论】:
-
我想从 web 获取 html 以显示在 textview 中
标签: android html url android-webview