如何使用wherequalto标签从json检索数据

时间:2018-10-29 15:27:20

标签: android json

大家好,我正在使用json数据创建应用程序

[{"que_id":5,"name":"Jind","question":"In which city of Haryana was the Mahabharata composed by Maharishi Vedavas?","answer":"Kurukshetra"}]

我正在从其他RecyclerAdapter使用意图字符串多余名称获取字符串

String Name = getIntent().getStringExtra("name");

我只希望显示包含名称的数据

如何在代码中使用wherequalto标记以仅显示包含name的数据, 我从recycleradapter中检索到了字符串名称

private void jsonRequest() {
    request = new JsonArrayRequest(JSON_URL, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            JSONObject jsonObject = null;
            for (int i=0; i < response.length();i++){
                try {
                    jsonObject = response.getJSONObject(i);
                    QuestionDistrict anime = new QuestionDistrict();
                    anime.setQuestion(jsonObject.getString("question"));
                    anime.setName(jsonObject.getString("name"));
                    anime.setAnswer(jsonObject.getString("answer"));
                    listAnime.add(anime);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            setuprecyclerview(listAnime);

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

        }
    });

0 个答案:

没有答案