I am fetching the menucode from mysql database to android. if i clicking on item in listview and codez=1 means it navigate to another page else go to another page
JSONArray json = jArray.getJSONArray("mainmenu");
final List<String> codez=new ArrayList<String>();
for ( i = 0; i < json.length(); i++) {
JSONObject e = json.getJSONObject(i);
codez.add(e.getString("menucode"));
}
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println(codez);
// TODO Auto-generated method stub
if(codez.equals("1"))
{
Intent intent=new Intent(getApplicationContext(),FoodMenu.class);
startActivity(intent);
}else
{
}
}
});
it prints all codes but not navigate can u please tell me the solution for above code
codezis aList, not aString. So when you try to compare it to"1", the comparison will always fail. Did you mean to choose one of the entries in the list instead?