2012-04-26 2 views

답변

0

귀하의 질문은 매우 명확하지 않다. 먼저 json을 파싱해야합니다. 구문 분석 된 데이터를 ArrayList (Bundle)에 넣을 수 있습니다. 다음과 같이 뭔가를 수행

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

+0

죄송합니다. 나는 당신의 질문을 얻지 않았다! – jtanveer