응답으로 JSON을 반환하는 웹 서비스를 사용하고 있습니다. 나는 응답을 파싱하고 객체의 목록을 만들고 싶다. 안드로이드에서 파싱 된 데이터를 UI에 표시하는 방법을 모르겠습니다. 여기서 사용자는 목록 (즉, 두바이 몰 또는 두바이 미디어 도시 또는 두바이 축제)에서 하나의 항목을 선택할 수 있습니다.android에서 JSON을 구문 분석하고 ListVIew에서 데이터 목록을 표시하려면 어떻게해야합니까?
public class MyLocation extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
initButtons();
initMapView();
initMyLocation();
jObject=getJSONFile("http://loyaltier.com/app/mobile/code/places/Maps.php");
}
private JSONObject getJSONFile(String URL) {
JSONObject jObject=null;
HttpGet httpGet=new HttpGet(URL); //http://loyaltier.com/app/mobile/code/places/Maps.php
HttpClient httpClient=new DefaultHttpClient();
HttpResponse httpResponse;
StringBuilder stringBuilder=new StringBuilder();
try{
httpResponse=httpClient.execute(httpGet);
HttpEntity httpEntity=httpResponse.getEntity();
InputStream inputStream=httpEntity.getContent();
int c;
while((c=inputStream.read())!=-1){
stringBuilder.append((char)c);
}
}catch(Exception e){
e.printStackTrace();
}
try{
jObject=new JSONObject(stringBuilder.toString());
}catch(JSONException e){
Log.e("Log_tags ", "Error parsing data "+e.toString());
}
return jObject;
}
}
같은 지점 ID로 등 JSON을 통해 JSON 요소에 액세스 할 수 없습니까? 잭슨 만 사용합니까? 감사합니다 – user1797707
잭슨 파싱 코드와 자바 빈 클래스를 게시하시기 바랍니다 ... –