title: Iterate loop inside getView() method of ArrayAdapter<CustomWrapperClassObject>
body: <p>I have a data wrapper class where i set &amp; get some values, adding to this i have some dynamic values coming from server and i have added a SortedMap in this wrapper class to set when i receive it from server without knowing what data is that, and then i am adding this CustomWrapperClassObject into a ArrayList, got to display ArrayList data inside a listview.</p>
  
  <p>Adapter extends ArrayAdapter</p>
  
  <p>Now when i try to iterate ArrayList.get(position), it returns a customObject. All other values set fine but when i get a SortedMap and try to iterate through its keys. <strong>SortedMap values are mixed up in list rows.</strong> Like view 1 in listview contains  values for the second view as well and as I scroll down and up values are being added in all the views.</p>
  
  <p>Appreciate any help.</p>
  
  <pre><code>class CustomWrapperClassObject{
   public String a;
   public String b;
   SortedMap&lt;String,String&gt; dynamicValues = new TreeMap&lt;String,String&gt;();
  
   public String getA(){
   }
   public void setA(String a){
   }
   ====same way for b=====
   public SortedMap&lt;String,String&gt; getDynamicValues(){
   }
   public void setDynamicValues(SortedMap&lt;String,String&gt; values){
   }
  }
  </code></pre>
  
  <p>getView method of ArrayAdapter&lt;> =========================================================</p>
  
  <pre><code>public View getView(final int position, View convertView, ViewGroup parent) 
          {
              View v = convertView;
              ViewHolder holder = null;
  
              if (v == null) 
              {
                  holder=new ViewHolder();  
                  v = vi.inflate(R.layout.row_item, null); 
  
                  holder.a=(TextView) v.findViewById(R.id.tv_a);
                  holder.b=(TextView)v.findViewById(R.id.tv_b);
                  holder.dynamicValue=(TextView)v.findViewById(R.id.tv_dynamic);
  
  
                  v.setTag(holder);
              }
              else
                  holder=(ViewHolder)v.getTag();
  
              CustomWrapperClassObject customWrapperClassObject= ArrayList.get(position);
  
  
              holder.a.setText(customWrapperClassObject.getA());
              holder.b.setText(customWrapperClassObject.getB());
  
  
              if(customWrapperClassObject.getDynamicValues()!= null &amp;&amp; customWrapperClassObject.getDynamicValues().size() &gt; 0)
              {
                  SortedMap&lt;String,String&gt; mDataObject =  customWrapperClassObject.getDynamicValues();
                  Set&lt;String&gt; keySet = mDataObject.keySet();
                  String[] keys = keySet.toArray(new String[keySet.size()]);
  
                  for(int i = 0 ; i &lt; keys.length ; i++)
                  {
                      holder.dynamicValue.append(keys[i]+":"+mDataObject.get(keys[i]+"\n");
  
  
                  }
              }
  
              return v; 
          }
      }
  </code></pre>