// XML node keys
private String KEY_FEATURES = "features"; // parent node
private String KEY_PROPERTIES = "properties";
private String KEY_TITLE = "title"; // title or place
private String KEY_GEOMETRY = "geometry";
private String KEY_COORDINATES = "coordinates";
private String KEY_geolat = "latitude"; // lat
private String KEY_geol; // long
/*
private LayoutInflater mInflater;
private FacebookFacade facebook;
private FacebookEventObserver facebookEventObserver;*/
ProgressDialog progress;
private HandleJSON obj;
int counter = 1;
int flag = 0;
Intent i;
Intent googlemap;
// ListView list;
Context context;
Handler handle = new Handler();
ArrayList<HashMap<String, String>> menuItems= new ArrayList<HashMap<String, String>>();
ArrayList<Item_DTO> Items = new ArrayList<Item_DTO>();
Item_DTO nn = new Item_DTO();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
setContentView(R.layout.sub_list);
populatelist();
super.onResume();
}
protected void populatelist() {
c
progress = new ProgressDialog(context);
progress.show();
// registerForContextMenu(list);
// json comes here ......
obj = new HandleJSON(URL);
obj.fetchJSON();
Toast.makeText(getApplicationContext(), "data fetch",2000).show();
HashMap<String, String> map = new HashMap<String, String>();
// HashMap<String, String> map = new HashMap<String, String>();
while (obj.parsingComplete) {
// creating new HashMap
map.put(KEY_TITLE, nn.getTitle());
map.put(KEY_geolong, nn.getLongitude());
map.put(KEY_geolat, nn.getLatitude());
System.out.print("counter :-" +counter);
//Toast.makeText(getApplicationContext(), "title "+KEY_TITLE,2000).show();
// Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
counter++;
menuItems.add(map);
}
SimpleAdapter sAdapter = new SimpleAdapter(this, menuItems,
R.layout.sub_listview,
new String[] { KEY_TITLE, KEY_geolong, KEY_geolat },
new int[] { R.id.txtTitle, R.id.txtLong,R.id.txtLat });
setListAdapter(sAdapter);
}
}Add a code snippet to your website: www.paste.org