不想问太久。只是我想如何在 oncreate 中调用用户函数?还需要我每次都使用 throw catch 吗?
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();
}
public JSONObject users() throws ClientProtocolException, IOException
{
StringBuilder URL = new StringBuilder();
HttpGet get = new HttpGet(url);
HttpResponse r = client.execute(get);
int status = r.getStatusLine().getStatusCode();
tvStatus.setText(status);
return null;
}
}