title: Android ListView custom layout
body: <p>I have a ListView in my Activity and for each row Im using my custom layout with a TextView and two Buttons. When I click any of these two buttons, I want a certain action to be performed. In my ArrayAdapter, in getView method, I set onClickListeners to these two buttons.</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
  
      View v = convertView;
      if (v == null) {
          v = li.inflate(R.layout.process_row, null);
      }
  
  
      final Button processCheck = (Button) v.findViewById(R.id.processCheck);
      processCheck.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              if (process.isChecked() == false) {
                  process.setChecked(true);
                  processCheck.setBackgroundColor(Color.BLUE);
              }
              else {
                  process.setChecked(false);
                  processCheck.setBackgroundColor(Color.RED);
              }
  
          }
      });
  
      return v;
  }
  </code></pre>
  
  <p>ArrayList holds objects of mz custom Class Process and process in the code is an instance of  this class. So now when I click this button in one of the ListView rows, I would expect to change the boolean variable in the given Process instance and change the color of the button. That happens, but not only with this one row, but some 3-4 more. So after clicking, I have some 5 changed buttons instead of one. Do you know what im doing wrong here? Note that I dont know the ListActivity coding very well, most of the code is actually copied and edited a little bit from an example file. Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>The problem is probably only with the layout somewhere. When I click the button, more of them change color but only the Process where i clicked has its boolean value changed.</p>