【问题标题】:How can I filter JSON listview如何过滤 JSON 列表视图
【发布时间】:2016-11-06 18:51:58
【问题描述】:

我想要在列表中显示的是equals(London) 中的字符串:

String location =  respons.getString("location"); 

如果它等于曼彻斯特,我不希望它出现在列表中:

for (int i = 0; i < jsonArray.length(); i++) {

    JSONObject respons =jsonArray.getJSONObject(i);  
    String id = respons.getString("id");
    String location =  respons.getString("location");
    String info = respons.getString("name");
    String img = respons.getString("img");

    listitmes.add(new Listitme(id, location, info, img));
    listAllItme();

}

【问题讨论】:

    标签: android arrays json objectlistview


    【解决方案1】:
    JSONObject respons =jsonArray.getJSONObject(i);
    // do your test hire if respons.getString("location") equlas the String "manchestar"
    if(respons.getString("location").equlas("manchestar")){
        String id=respons.getString("id");
        String info=respons.getString("name");
        String img=respons.getString("img");
        listitmes.add(new Listitme(id,location,info,img));
        listAllItme();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 2017-06-26
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      相关资源
      最近更新 更多