応答としてJSONを返すWebサービスを使用しています。応答を解析して、オブジェクトのリストを作成したいと思います。解析したデータをAndroidのUIに表示する方法がわかりません。ここで、ユーザーはリストから1つのアイテムを選択できます(つまり、ドバイモール、ドバイメディアシティ、またはドバイフェスティバル)。
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;
}
}