Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android json数据不是';t在布局中显示,但当我从另一个布局来到这里时显示_Android_Json_Fragment - Fatal编程技术网

Android json数据不是';t在布局中显示,但当我从另一个布局来到这里时显示

Android json数据不是';t在布局中显示,但当我从另一个布局来到这里时显示,android,json,fragment,Android,Json,Fragment,json数据不会显示在布局中,但会显示活动何时完成 我为Jsonobject编写了以下代码。我正在应用程序中使用选项卡。最初它不显示,但当我从另一个选项卡移动到我的json选项卡时,它显示json对象的数据 请帮我找出错误 RequestQueue queue = Volley.newRequestQueue(getActivity()); JsonObjectRequest myReq = new JsonObjectRequest(Request.Method.GET, "http:

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);
RequestQueue=Volley.newRequestQueue(getActivity());
JsonObjectRequest myReq=新的JsonObjectRequest(Request.Method.GET)http://192.168.18.235:7777/cric/news.php",
无效的
新的Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
试一试{
JSONArray posts=response.getJSONArray(“数据”);
对于(int i=0;i
请调用
适配器.notifyDataSetChanged()
选项卡Activity.onContentChanged()
以更新视图。

由适配器.notifyDataSetChanged()执行它不工作,我无法理解选项卡Activity.onContentChanged()方法。请您用breif解释一下。您在哪里显示存储在
新闻提要中的对象?
?我已经用ConvertView显示了这一点。我已经重写了getView方法,并按标题、作者设置了它。这意味着您正在使用
ListView
来显示数据。对吗?那么您的
列表视图的适配器在哪里?