I am showing data in listview from json using AsynTask.
Code is here.
public class MenuTask extends AsyncTask<String, String, String> { @Override protected String doInBackground(String... arg0) { // TODO Auto-generated method stub List<NameValuePair> params = new ArrayList<NameValuePair>(); // Getting JSON String from URL.............. JSONObject jsonObject = jParser.makeHttpRequest( "http://smartaway.dk/json/submenu.php?resid=" + res_id, "POST", params); try { bestdeal = jsonObject.getJSONArray(TAG_MENU); // / LOOping through AllEvents........ for (int i = 0; i < bestdeal.length(); i++) { JSONObject e = bestdeal.getJSONObject(i); String resname = e.getString(TAG_MENUNAME); String city_state = e.getString(TAG_PRICE); // Creating New HAsh Map......... HashMap<String, String> map = new HashMap<String, String>(); // adding each child node to HashMap key => value // map.put(TAG_ID, id); map.put(TAG_MENUNAME, resname); map.put(TAG_PRICE, city_state); /* * map.put(TAG_STREET, street); map.put(TAG_COUSINE, * cousine); map.put(TAG_RES_LOGO, reslogo); */ // adding HashList to ArrayList bestdeal_list.add(map); } // } } catch (JSONException e) { e.printStackTrace(); } return null; } @SuppressWarnings("deprecation") @Override protected void onPostExecute(String result) { super.onPostExecute(result); /* * if(bestdeal_list.isEmpty()){ AlertDialog alertDialog=new * AlertDialog.Builder(getParent()).create(); * alertDialog.setTitle("No Best Deal Found"); * alertDialog.setButton("Ok", new DialogInterface.OnClickListener() * { * * @Override public void onClick(DialogInterface dialog, int which) * { * * * } }); alertDialog.show(); } else{ */ /* * if (bestdeal_list.isEmpty()) { * Toast.makeText(getApplicationContext(), "Empty Menu", * Toast.LENGTH_LONG).show(); } else{ */ runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( RestaurantDetails.this, bestdeal_list, R.layout.menu_list, new String[] { TAG_MENUNAME, TAG_PRICE }, new int[] { R.id.textView1, R.id.textView3 }); list.setAdapter(adapter); } }); } // } } All things are working fine but i want to modify my code by dividing the listview into sections. I want first 4 list items under category 1 the other 4 list items under category 2. I dont want expandable listview. Just want to modify above mentioned code.