Custom ArrayAdapter in android updating the view of 1st entry only in ListActivity
<p>I have a ListActivity showing a list of items and there is a ImageView at the right end of each item which shows an arrow icon at the beginning.After a certain button press I want to replace those arrow icons with a delete icon.For this I have changed the ArrayAdapter of the ListView and called notifyDataSetChanged().In the ArrayAdapter's getView method I have set the ImageResource for the ImageView but the change is not showing on the list only the 1st entry has a changed icon.</p>

<p>Here is the ArrayAdapter code:</p>

<pre><code>private class CCAdapter extends ArrayAdapter&lt;CCcenter&gt;{

    ArrayList&lt;CCcenter&gt; items;
    int mode;
    public CCAdapter(Context context, int textViewResourceId, ArrayList&lt;CCcenter&gt; Items,int m) {
        super(context, textViewResourceId, Items);
        this.items=Items;
        this.mode=m;
        // TODO Auto-generated constructor stub
    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.lisitem, null);
            }
            final CCcenter o = items.get(position);
            if (o != null) {

                    TextView title = (TextView) v.findViewById(R.id.ttl_txt);
                    TextView desc=(TextView)v.findViewById(R.id.desc_txt);
                    TextView dist=(TextView)v.findViewById(R.id.dist_txt);
                    ImageView icon=(ImageView)findViewById(R.id.lst_icon);
                    RatingBar rating=(RatingBar)findViewById(R.id.lst_ratings);

                    if(title!=null)
                    {
                        title.setText(o.title);
                    }
                    if(desc!=null)
                    {
                        desc.setText(o.desc);
                    }
                    if(dist!=null)
                    {
                        dist.setText(o.dist);
                    }
                    if(rating!=null)
                    {
                        rating.setRating(o.rating);
                    }
                    if(icon!=null) //edit mode
                    {
                        if(this.mode==1)
                        {
                            icon.setImageResource(R.drawable.arrow);
                        }
                        else
                        {
                            icon.setImageResource(R.drawable.dlet);
                        }
                    }
            }
            return v;
    }

}
</code></pre>

<p>In the OnClick method of the button I do the following:</p>

<pre><code>CCAdapter mAdapter=new CCAdapter(context, R.layout.lisitem, CCS,2);
             MyList.this.setListAdapter(mAdapter);
                   mAdapter.notifyDataSetChanged();
             MyList.this.getListView().invalidateViews();
</code></pre>

<p>But after doing this only the 1st entry of the list have a delete icon others just show the default arrow icon.What am I doing wrong?                </p>
