title: Android Listview showing duplicate entries
body: <p>I tried to display values from json array in listview. But it's displaying the duplicate entries in all the listview buttons. Here is my code</p>
  
  <p>MenuFragment:</p>
  
  <pre><code>  JSONObject json = jParser.makeHttpRequest(CommonUtilities.SERVERURL_GET_MENUS, "GET", params);
            SUCCESS = json.getString(TAG_SUCCESS);
            if (SUCCESS.equalsIgnoreCase("false")) {
                JSONArray jsonarrays = json.getJSONArray("sub_menus");
                HashMap&lt;String, String&gt; sb = new HashMap&lt;String, String&gt;();
                for (int k = 0; k &lt; jsonarrays.length(); k++) {
                     JSONObject main_menus = jsonarrays.getJSONObject(k);
                     SUB_MENU_ID = main_menus.getString("sub_menu_id");
                     SUB_MENU_NAME = main_menus.getString("sub_menu_name");
                     sb.put(SUB_MENU_ID, SUB_MENU_NAME);
                     submenus.add(sb);
                  } }
  
    protected void onPostExecute(String result) {
        try {
           submenuadapter=new SubmenuCategoryAdapter(submenus,getActivity());
           sb_list.setAdapter(submenuadapter);
        }
  </code></pre>
  
  <p>SubmenuCategoryAdapter:</p>
  
  <p>Adapter contains button to display the list values. </p>
  
  <pre><code>public class SubmenuCategoryAdapter extends BaseAdapter {
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; mainmenu;
      HashMap&lt;String, String&gt; mainmenumap = new HashMap&lt;String, String&gt;();
      Context con;
      public SubmenuCategoryAdapter(ArrayList&lt;HashMap&lt;String, String&gt;&gt; mainmenu, Context con) {
          super();
          this.mainmenu = mainmenu;
          this.con = con;
      }
      @Override
      public int getCount() {
          return mainmenu.size();
      }
      @Override
      public Object getItem(int position) {
          return position;
      }
      @Override
      public long getItemId(int position) {
          return position;
      }
      @SuppressLint("ViewHolder")
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          final Holder holder = new Holder();
          LayoutInflater layoutInflater = (LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          mainmenumap = mainmenu.get(position);
          View submenuview = layoutInflater.inflate(R.layout.submenu_button, null);
          holder.submenu_btn=(Button)submenuview.findViewById(R.id.submenu_layout_button);
          String btn_name=mainmenu.get(position).toString();
          holder.submenu_btn.setText(btn_name);
          return submenuview;
      }
      public class Holder {
        Button submenu_btn;
      }
  }
  </code></pre>