直接上示例:
public void getList(String cmdStr, int index, int type, ArrayList> mList) { try { JSONArray gethotlist = new JSONObject(cmdStr).getJSONArray("list"); JSONObject jso = (JSONObject)gethotlist.opt(index); JSONArray jContent = jso.getJSONArray("content"); for (int j = 0; j < jContent.length(); j++) { JSONObject mJContent = (JSONObject)jContent.opt(j); HashMap map = new HashMap(); switch(type) { case 0: map.put("ItemTitle", getSecList(mJContent).name); System.out.println("name:"+getSecList(mJContent).name); break; case 1: map.put("ItemUrl", getSecList(mJContent).url); map.put("ItemTitle", getSecList(mJContent).name); System.out.println("url:"+getSecList(mJContent).url); System.out.println("name:"+getSecList(mJContent).name); break; case 2: map.put("ItemLen", getSecList(mJContent).len); System.out.println("len:"+getSecList(mJContent).len); break; default: break; } mList.add(map); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void test() { mDqJson.getList(cmdStr, index, GET_URL, urlList); if (!urlList.isEmpty()) { Iterator> it = urlList.iterator(); HashMap hash; Object value = new Object(); Object nameValue = new Object(); int i = 0; while(it.hasNext()) { hash = it.next(); HashMap map = new HashMap(); value = hash.get("ItemUrl"); nameValue = hash.get("ItemTitle"); System.out.println("value-url:"+value.toString()); System.out.println("value-name:"+nameValue.toString()); } } }

更多相关文章

  1. android倒计时控件示例
  2. Android部分控件示例汇总
  3. Android解析Excel文档完整示例
  4. Android裁剪图像实现方法示例
  5. Android手势操作示例(上/下/左/右的判断)
  6. Android ApiDemos示例解析(18):App->Activity->Wallpaper
  7. Android判断当前网络是否可用--示例代码
  8. android Shader类简介_渲染图像示例
  9. Android ApiDemos示例解析(9):App->Activity->Persistent State

随机推荐

  1. Android ListView SimpleAdapter ArrayLi
  2. Android SQLiteOpenHelper(手机数据库)
  3. android的TextUtils.substring与.net的不
  4. 【android】设置View字体点击变色和边框
  5. Android O版本Call对象解析
  6. Android 自定义键盘中禁用点击预览弹窗
  7. android-控件样式(Theme)自定义
  8. Android(安卓)应用初始化及窗体事件的分
  9. xUtils3.3.x注解使用实例
  10. Android 中比 Timer 更好方法