所以我正在研究JSON,并且我有一个获取JSON的URL,但出于某种原因,它说
连接到static-182-18-161-240.ctrls.in/218.93.250.18:7070超时
public class MainActivity extends AppCompatActivity {
ListView listView;
Response responseObj;
CustomAdapter adapter;
String url= "http://182.18.161.240:7070/sfaweb-1.1.015/get/retailers/dl-0004/2";
Gson gson;
AsyncHttpClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.rtlist);
client = new AsyncHttpClient();
client.get(MainActivity.this, url, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
String responsestr = new String(responseBody);
gson = new Gson();
responseObj = gson.fromJson(responsestr, Response.class);
adapter = new CustomAdapter(MainActivity.this, responseObj);
listView.setAdapter(adapter);
}
这是我的代码..我还在Manifest中添加了互联网权限。 帮助将深表赞赏..