我有一个包含一堆不同类别的项目的 json 文件,我想检查类别,如果与给定条件匹配,我想在 listview 中显示,这就是我想出的.. 但它确实有效,listview 是空的
ArrayList<HashMap<String, String>> eventsList = new ArrayList<HashMap<String, String>>();
try {
JinnerObject = Jobject.getJSONObject("data");
Jarray = JinnerObject.getJSONArray("events");
for(int i = 0; i < Jarray.length(); i++){
JeventObject = Jarray.getJSONObject(i);
String _EV_OP1 = JeventObject.getString(EV_OP1);
String _EV_OP2 = JeventObject.getString(EV_OP2);
String _EV_COEF1 = JeventObject.getString(EV_COEF1);
String _EV_COEF2 = JeventObject.getString(EV_COEF2);
String _EV_STIME = JeventObject.getString(EV_STIME);
String _EV_HOST = JeventObject.getString(EV_HOST);
String _EV_DESC = JeventObject.getString(EV_DESC);
String _EV_TIP = JeventObject.getString(EV_TIP);
String _EV_CAT = JeventObject.getString(EV_CAT);
if(_EV_CAT == C){
HashMap<String, String> Events_map = new HashMap<String, String>();
Events_map.put(EV_OP1, _EV_OP1);
Events_map.put(EV_OP2, _EV_OP2);
Events_map.put(EV_COEF1, _EV_COEF1);
Events_map.put(EV_COEF2, _EV_COEF2);
Events_map.put(EV_STIME, _EV_STIME);
Events_map.put(EV_HOST, _EV_HOST);
Events_map.put(EV_DESC, _EV_DESC);
Events_map.put(EV_TIP, _EV_TIP);
eventsList.add(Events_map);
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}