Zaid Alshami Zaid Alshami - 28 days ago 6
Android Question

how can i filter json listview

//what i want is to show in the list is the String that equals(london) in:
//String location = respons.getString("location");
//if it equlas(manchestar)i dont want it to be in the list

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();

};

Answer
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();
}
Comments