change image of imageview on click list position android
<p>hello friends i am making an application in which there are list view contain image and text and when i click on list position then i want to change the image of imagevies at corresponding position only.and when i change the position selection then first would come to its previous stage means unselected image and selected row show selected image in that row so how to achive this.</p>

<p>i take the help from this link     <a href="http://blog.sptechnolab.com/2011/02/01/android/android-custom-listview-items-and-adapters/" rel="nofollow">http://blog.sptechnolab.com/2011/02/01/android/android-custom-listview-items-and-adapters/</a>    for display image and text in one row .so what effort required to change the image of row on selection of list.
help would be greatly appreciated....thanks</p>

<pre><code>      public class MainMenu extends ListActivity {
  Context context = null;


      private boolean[] itemToggled;

private LayoutInflater mInflater;
private Vector&lt;RowData&gt; data;
RowData rd;
static final String[] title = new String[] {
        "Add/Edit Expences", "View Curent Report Status",   
"Attach Reciepts ","Settings"       };
static final String[] detail = new String[] {
        "",""," ",""
    };
private Integer[] imgid = {
 R.drawable.add_expense_off,R.drawable.view_status_off,R.drawable.attach_receipts_off,
  R.drawable.settings_off
};
        @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainmenulist);

mInflater = (LayoutInflater) getSystemService(
Activity.LAYOUT_INFLATER_SERVICE);
data = new Vector&lt;RowData&gt;();
for(int i=0;i&lt;title.length;i++){
try {
    rd = new RowData(i,title[i],detail[i]);
    } catch (ParseException e) {
        e.printStackTrace();
   }
   data.add(rd);
}
   CustomAdapter adapter = new CustomAdapter(this, R.layout.list,
                                     R.id.title, data);
   setListAdapter(adapter);
   getListView().setTextFilterEnabled(true);
}
   public void onListItemClick(ListView parent, View convertView, int position,
                                                                long id) { 
        super.onListItemClick(parent, convertView, position, id);


       if(position==0){



       }

       parent.setSelector( R.drawable.listselectedstate);         


   Toast.makeText(getApplicationContext(), "You have selected"
                +(position+1)+"th item",  Toast.LENGTH_SHORT).show();
}
       private class RowData {
       protected int mId;
       protected String mTitle;
       protected String mDetail;
       RowData(int id,String title,String detail){
       mId=id;
       mTitle = title;
       mDetail=detail;
    }
       @Override
       public String toString() {
               return mId+" "+mTitle+" "+mDetail;
       }
}
  private class CustomAdapter extends ArrayAdapter&lt;RowData&gt; {
  public CustomAdapter(Context context, int resource,
                        int textViewResourceId, List&lt;RowData&gt; objects) {               
 super(context, resource, textViewResourceId, objects);
}
  @Override
      public View getView(int position, View convertView, ViewGroup parent) {   
       ViewHolder holder = null;
       TextView title = null;
       TextView detail = null;
       ImageView i11=null;
       RowData rowData= getItem(position);
       if(null == convertView){
            convertView = mInflater.inflate(R.layout.list, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
 }
             holder = (ViewHolder) convertView.getTag();
             title = holder.gettitle();
             title.setText(rowData.mTitle);
             detail = holder.getdetail();
                detail.setText(rowData.mDetail);                                                     
             i11=holder.getImage();

          i11.setImageResource(imgid[rowData.mId]);


             return convertView;
}
            private class ViewHolder {
            private View mRow;
            private TextView title = null;
            private TextView detail = null;
            private ImageView i11=null; 
            public ViewHolder(View row) {
            mRow = row;
 }
         public TextView gettitle() {
             if(null == title){
                 title = (TextView) mRow.findViewById(R.id.title);
                }
            return title;
         }     
         public TextView getdetail() {
             if(null == detail){
                  detail = (TextView) mRow.findViewById(R.id.detail);
                    }
           return detail;
         }
        public ImageView getImage() {
             if(null == i11){
                  i11 = (ImageView) mRow.findViewById(R.id.img);
                                      }
                return i11;
        }
     }
   } }
</code></pre>
