public void onClick(View v) {
TextView tv_1 = (TextView) findViewById(R.id.tv1);
String httpUrl = "http://www.517yueye.com/android.aspx";
HttpGet httpRequest = new HttpGet(httpUrl);
try {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResp /> // 请求成功
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 取得返回的字符串
String strResult = EntityUtils.toString(httpResponse
.getEntity());
tv_1.setText(strResult);
} else {
tv_1.setText("请求错误!");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
把HttpResponse httpResp改为HttpResponse httpResp= httpClient.execute(httpRequest );看有用没?