我可以从数据库中获取菜单代码,我可以在 for 循环中打印意味着它会打印所有菜单代码。如果我打印循环侧意味着它只打印最后一个值
my code
JSONArray json = jArray.getJSONArray("mainmenu");
for ( i = 0; i < json.length(); i++) {
JSONObject e = json.getJSONObject(i);
map.put("itemcode", e.getString("menucode")); //here i print all values
}
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println(map.get("itemcode"));//here i print only last value(here i want print all values how can i do this)
// TODO Auto-generated method stub
Intent intent=new Intent(getApplicationContext(),FoodMenu.class);
startActivity(intent);
}
});
在循环之外我也想打印所有菜单代码..请帮助我