前端之家收集整理的这篇文章主要介绍了
遍历JSONObject,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public void initialFilter(JsonNode filter) {
// 智能数据来源
smartDataList = new ArrayList<String>();
String smart = filter.get("order_by").toString();
try {
JSONObject obj = new JSONObject(smart);
Iterator<String> keys = obj.keys();
while (keys.hasNext()) {
// 这是把所有的key添加到list了
smartDataList.add(keys.next());
}
} catch (JSONException e) {
e.printStackTrace();
}
ArrayAdapter<String> smartAdapter = new ArrayAdapter<String>(mActivity,android.R.layout.simple_list_item_1,smartDataList);
smartView = LayoutInflater.from(mActivity).inflate(R.layout.store_filter_smart,null);
smartListView = (ListView) smartView.findViewById(R.id.lv_shop_smart);
smartListView.setAdapter(smartAdapter);
}
原文链接:https://www.f2er.com/json/289942.html