title: How to change color of text when click in base adapter in android
body: <p>I am using Base Adapter in my listview for populating data in android. but i am just begineer in android. so, little bit confusing in base Adapter . I have display data in base Adapter.</p>
  
  <p>Here, My main problem is, If i click position 0 then i want to change color of txtview of position. If i click position 5 then change color of textview of position 5 others remains same color.</p>
  
  <p>Just clickable position texview change to red other white.</p>
  
  <pre><code> if 0 - red - clicked
         1-white
         2 - white
         3-white
         4- white
         5- white
  
  if 0 - white
         1-white
         2 - white
         3- red- clicked
         4- white
         5- white
  </code></pre>
  
  <p>Here Code of mine:</p>
  
  <pre><code>ArrayList&lt;Geo&gt; list;
  public class TestListAdapter extends BaseAdapter {
  
      public TestListAdapter(Context context, int textViewResourceId,
              ArrayList&lt;Geo&gt; objects, String name_of_APP) {
  
          this.objects = objects;
          contx = context;
          layoutInflator = LayoutInflater.from(contx);
          _APP = name_of_APP;
          VVV = layoutInflator.inflate(R.layout.row_cell_multilevel, null);
        list=objects;
          for(int i=0;i&lt;list.size();i++){
              itemPos.add(i);
          }
      }
  
  //  @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          final ViewHolder holder;
          try{
              CC = getItem(position);//objects.get(position);
              if (convertView == null){
  
                  convertView = View.inflate(contx, R.layout.row_cell_multilevel, null);
                  holder = new ViewHolder();
                  holder.txtName = (TextView) convertView.findViewById(R.id.row_cell_text_multilevel);
                  holder.btn = (Button) convertView.findViewById(R.id.row_cell_btn_multilevel);
                  convertView.setTag(holder);
              }else{
                  holder = (ViewHolder) convertView.getTag();
              }
  
              holder.btn.setTag(position);
              holder.txtName.setTag(position);
  
              holder.txtName.setText(CC.Name);
  
              holder.txtName.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View v) {
                          String name = holder.txtName.getText().toString();
                      Toast.makeText(contx, "You Have Choosed " + name  , Toast.LENGTH_SHORT).show();
        if (itemPos.contains(position)) {
       holder.txtName.setTextColor(Color.RED); notifyDataSetChanged();} 
           else {
       holder.txtName.setTextColor(Color.WHITE); notifyDataSetChanged();}
          }
              });
  
  
          }catch (Exception e){
              Log.d("Exception", "" + e.getMessage());
          }
          return convertView;
      }
  
      static class ViewHolder {
          TextView        txtName;
      }
  
      //@Override
      public int getCount() {
          // TODO Auto-generated method stub
          return this.objects == null ? 0 : this.objects.size();
      }
  
      //@Override
      public Geo getItem(int position) {
          // TODO Auto-generated method stub
          return this.objects == null ? null : this.objects.get(position);
      }
  
  //      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  
      public String getID() {
          Log.e(post, "post id=" + CC.ID);
          return CC.ID;
      }
  
  }
  </code></pre>