2012-04-26 78 views

回答

0

你的问题不是很清楚。你需要先解析json。您可以将解析的数据放入BundleArrayList。不喜欢下面的内容:

String response = getResponseFromGoogleMaps(); //this function will fetch the response. write it in your way 
ArrayList<Bundle> list = new ArrayList<Bundle>(); 
try { 
     JSONObject json = new JSONObject(response); 
     JSONArray routes = json.getJSONArray("route"); 
     JSONArray legs = routes.getJSONArray(0); 
     JSONArray steps = legs.getJSONArray(0); 
     for(int i=0;i<steps.length();i++) { 
      JSONObject singleStep = steps.getJSONObject(i); 
      JSONObject duration = singleStep.getJSONObject("duration"); 
      Bundle dur = new Bundle(); 
      dur.putString("text", duration.getString("text")); 
      dur.putString("value", duration.getString("value")); 
      JSONObject distance = singleStep.getJSONObject("distance"); 
      Bundle dis = new Bundle(); 
      dis.putString("text", distance.getString("text")); 
      dis.putString("value", distance.getString("value")); 
      Bundle data = new Bundle(); 
      data.putBundle("duration", dur); 
      data.putBundle("distance", dis); 
      list.add(data); 
     } 
} catch (JSONException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
} 

然后创建它处理ArrayList<Bundle>自己的列表适配器(应该从BaseAdapter延伸)。你完成了!

+0

在这种情况下,就像ListAdapter一样? – user1265628 2012-04-27 17:09:29

+0

对不起?我没有得到你的问题! – jtanveer 2012-04-28 09:01:30