hello

first of all let me tell u regarding ur track for JSON parsing and getting
address using a web service is right..
now here I'm sending u code that how I am used to parse the JSON data.. All
you have to do is check this specified URL and change the rest of the code
according your requirements..

code is given below

--------------------------------------------------------------------------------------------------------------------

ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String,
String>>();
        JSONObject json = JSONfunctions.getJSONfromURL("
http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=demo
");
        try{
        JSONArray  earthquakes = json.getJSONArray("earthquakes");
            for(int i=0;i<earthquakes.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = earthquakes.getJSONObject(i);
 map.put("id",  String.valueOf(i));
         map.put("name", "Earthquake name:" + e.getString("eqid"));
         map.put("magnitude", "Magnitude: " +  e.getString("magnitude"));
         mylist.add(map);
}
        }catch(JSONException e)        {
         Log.e("log_tag", "Error parsing data "+e.toString());
        }

        ListAdapter adapter = new SimpleAdapter(this, mylist ,
R.layout.main,
                        new String[] { "name", "magnitude" },
                        new int[] { R.id.item_title, R.id.item_subtitle });

        setListAdapter(adapter);



-------------------------------------------------------------------------------------------------------------------------------------

let me know whether it works or not for you...

thank you

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to