title: changing the background color of list item on button click event
body: <p>In my application im using custom list view with two buttons and a image view in each row of the list view. I want to do something like this:</p>
  
  <p>when a user press DONE button on the list view it should open a dialog box. In the dialog box i have something to show. </p>
  
  <ul>
  <li><strong>When dialog box is closed the background of the relevent list view item should be changed to some color</strong> and </li>
  <li><strong>when I refresh the list view that color change should be there</strong></li>
  </ul>
  
  <p>How can i do this. I know how to show a dialog box on a click event on the list button, but to changing the color of the background, *I have no idea how to do it... please give me some logics , code samples ideas....please...</p>
  
  <pre><code>public View getView(final int position, final View convertView, final ViewGroup parent) {
      // TODO Auto-generated method stub
      View vi = convertView;
      if(convertView==null)
          vi = inflater.inflate(R.layout.row_for_appoinments,null);
  
  
          final TextView firstname = (TextView) vi.findViewById(R.id.first_name);
          final TextView lastname = (TextView) vi.findViewById(R.id.last_name);
          final TextView startTime = (TextView) vi.findViewById(R.id.start_time);
          final TextView endTime = (TextView) vi.findViewById(R.id.end_time);
          final TextView date = (TextView) vi.findViewById(R.id.empty_field);
          final TextView hidID = (TextView) vi.findViewById(R.id.row_id_pationt);
          final TextView hidAppid = (TextView) vi.findViewById(R.id.appoinment_id_row);
  
           img = (ImageView) vi.findViewById(R.id.image);
  
  
          HashMap&lt;String, String&gt; song = data.get(position);
  
          firstname.setText(song.get("FirstName"));
  
          //Log.w("viewFirstName", firstName.toString());
  
  
          lastname.setText(song.get("LastName"));
          startTime.setText(song.get("StartTime"));
          endTime.setText(song.get("EndTime"));
          date.setText(song.get("Date"));
          hidID.setText(song.get("PersonId"));
          //Log.w("viewhidID", hidID.getText().toString());
          hidAppid.setText(song.get("AppointmentId"));
  
           theUrl = song.get("ImageURL");
  
  
  
  
          if(theUrl==null || theUrl.equalsIgnoreCase("") || theUrl.equalsIgnoreCase("")){
              Bitmap bImage = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.propic);
              img.setImageBitmap(bImage);
  
          }
          else{
  
              if (cancelPotentialDownload(theUrl, img)) {
  
                   BitmapDownloaderTask2 task = new BitmapDownloaderTask2(img);
                   DownloadedDrawable2 downloadedDrawable = new DownloadedDrawable2(task);
                   img.setImageDrawable(downloadedDrawable);
                   task.execute(theUrl);
               }
  
  
          }
  
          /*ImageButton direction = (ImageButton) vi.findViewById(R.id.direction);
          direction.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
              Toast.makeText(mContext, "under construction", Toast.LENGTH_LONG).show();
              }
          });
          */
  
  
  
          vi.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  String getPname = hidID.getText().toString();
  
                  Intent zoom=new Intent(parent.getContext(), Profile.class);  
                  zoom.putExtra("PatientID", getPname);
                  parent.getContext().startActivity(zoom);
  
  
  
              }
          });
  
  
  
          Button btnDone =  (Button) vi.findViewById(R.id.btnDone);
          btnDone.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  //convertView.setBackgroundColor(Color.GREEN);
              long id =  getItemId(position);
              String s = String.valueOf(id);
              //Toast.makeText(mContext, s, Toast.LENGTH_LONG).show();
              //((ViewGroup) convertView).getChildAt(position).setBackgroundColor(Color.GREEN);
  
              /*  //convertView.setBackgroundColor(Color.GREEN);
                  if(convertView.getId() == position){
                      convertView.setBackgroundColor(Color.GREEN);
                  }
                  else{
                      Toast.makeText(mContext, s, Toast.LENGTH_LONG).show();
                  }*/
  
  
              // HERE I WANT TO CHNAGE THE BACKGROUND COLOR
              // LIKE CHANGING COLOR OF THE ITEM WHEN WE TOUCH
              //BUT THE COLOR SHOULD REMAIN 
  
  
  
  
              }
          });
          return vi;
  }
  </code></pre>