json数据未在布局中显示但显示活动何时完成
我有以下Jsonobject代码。我在我的应用程序中使用选项卡。最初它没有显示但是当我从另一个选项卡移动到我的json选项卡时,它显示了json对象的数据。
请帮我找错。
RequestQueue queue = Volley.newRequestQueue(getActivity());
JsonObjectRequest myReq = new JsonObjectRequest(Request.Method.GET, "http://192.168.18.235:7777/cric/news.php",
null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray posts = response.getJSONArray("data");
for (int i = 0; i < posts.length(); i++) {
JSONObject temp = posts.getJSONObject(i);
String author = temp.getString("author");
String content = temp.getString("content");
String date = temp.getString("date");
String imageUrl = temp.getString("imageUrl");
String time = temp.getString("time");
String title = temp.getString("title");
String url = temp.getString("url");
Log.i("jsontag",title);
newsFeed.add(new NewsItem(title, content,R.drawable.ic_menu_gallery,author,"2-2-2018","1-05pm","https://www.inshorts.com/en/news/tardigrades-selected-among-1st-species-to-leave-solar-system-1509779328721","http://www.deepspace.ucsb.edu/projects/ets?utm_source=inshorts&utm_medium=referral&utm_campaign=fullarticle "));
}
}
catch (Exception e){
Log.i("myTag",e.toString());
}
}
},new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error) {
Log.i("errorTaf",error.toString());
}
}
);
queue.add(myReq);
答案 0 :(得分:0)
请调用2 Scenarios (1 pending, 1 passed)
6 Steps (2 skipped, 1 pending, 3 passed)
或adapter.notifyDataSetChanged()
更新视图。