2016-11-06 15 views
-2

Was ich will, ist in der Liste anzuzeigen ist der String, equals(London) in:Wie kann ich JSON Listenansicht filtern

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

wenn es nach Manchester gleich, ich will es nicht in der Liste sein:

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

} 

Antwort

0
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(); 
} 
+0

vielen Dank, es hat funktioniert :) –

+0

Sie sind willkommen. – SofDroid

Verwandte Themen