0
你好,我有這樣的JSON:閱讀2D JSON對象的Android
{"m1":
{"phone":"510000",
"lon":-75.5898195,
"postal":"050022",
"address":"cll 19",
"company":"my company",
"saved":true,
"address2":"adress my company",
"lat":6.2418782},
"m0":
{"phone":"85555555",
"lon":-75.5898195,'
"postal":"45895",
"address":"cll 65 d 54",
"company":"c1",
"saved":false,
"address2":"jhvbf",
"lat":6.2418782}
}
現在,當我在谷歌地圖的標記點擊,這些信息應該出現在一個抽屜佈局傳遞標記上檢索標記ID該函數:
private void openDrawerLayout(final Marker marker){
try {
JSONObject inf = markerId.getJSONObject(marker.getId());
//JSONObject inf = (JSONObject) markerId.get(marker.getId());
if(inf.getBoolean("saved")){
String companyJs = inf.getString("company");
String address1Js = inf.getString("address");
String address2Js = inf.getString("address2");
String postalJs = inf.getString("postal");
String phoneJs = inf.getString("phone");
company.setText(companyJs);
address1.setText(address1Js);
address2.setText(address2Js);
postal_code.setText(postalJs);
phone.setText(phoneJs);
}else{
address1.setText("");
address2.setText("");
postal_code.setText("");
phone.setText("");
}
} catch (JSONException e) {
e.printStackTrace();
}
當我使用這個功能markerId.getJSONObject(marker.getId()),被檢索永諾第一JSON對象(M1),需要關於如何獲取正確的ID標記JSON幫助