我无法理解 logcat 说什么,因为我对 android 开发还不是很老。这是logcat。代码如下..
public class Json extends Activity {
HttpClient client;
TextView tvStatus;
final static String url = "http://localhost/index.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.json);
tvStatus = (TextView) findViewById(R.id.tvStatus);
client = new DefaultHttpClient();
try {
int data = this.users();
String Data = String.valueOf(data);
tvStatus.setText(Data);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public int users() throws ClientProtocolException, IOException
{
StringBuilder URL = new StringBuilder(url);
HttpGet get = new HttpGet(URL.toString());
HttpResponse r = client.execute(get);
int status = r.getStatusLine().getStatusCode();
return status;
}
}
只是试图获取状态并附加到 tvStatus。问题和解决方案可能是什么?