title: Multiple checkboxes in list item android
body: <p>I'm trying to build a custom array adapter that has two checkboxes in each list item. When a checkbox is clicked I want to uncheck the other checkbox if it's checked. So either neither checkbox is checked or just one of them is. </p>
  
  <p>I think the issue I'm running into is I'm not clear how to reference the other checkbox from inside the onClickListener. Here's my code thus far:</p>
  
  <pre><code>public class PetWalkerAdapter extends ArrayAdapter&lt;ParseObject&gt;{
      protected Context mContext;
      protected List&lt;ParseObject&gt; mPets;
  
      public PetWalkerAdapter(Context context, List&lt;ParseObject&gt; pets) {
          super(context, R.layout.pet_walker_item, pets);
          mContext = context;
          mPets = pets;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
  
          if (convertView ==  null) {
              convertView = LayoutInflater.from(mContext).inflate(R.layout.pet_walker_item, null);
              holder = new ViewHolder();
              holder.petPictureView = (ImageView) convertView.findViewById(R.id.petPicture);
              holder.petNameLabel = (TextView) convertView.findViewById(R.id.petNameLabel);
              holder.ownerCheckBox = (CheckBox) convertView.findViewById(R.id.ownerCheckBox);
              holder.walkerCheckBox = (CheckBox) convertView.findViewById(R.id.walkerCheckBox);
              convertView.setTag(holder);
  
              // If owner check is toggled, uncheck walker
              holder.ownerCheckBox.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      CheckBox cb = (CheckBox) view;
                      ViewHolder petHolder = (ViewHolder) cb.getTag();
  
                      // Here's where the app crashes, 
                      if (petHolder.walkerCheckBox.isChecked()) {
                          petHolder.walkerCheckBox.setChecked(false);
                      }
                  }
              });
  
          }
          else {
              holder = (ViewHolder)convertView.getTag();
          }
  
          ParseObject pet = mPets.get(position);
  
          holder.petNameLabel.setText(pet.getString(ParseConstants.KEY_PET_NAME));
  
  
  
          return convertView;
      }
  
      private static class ViewHolder {
          ImageView petPictureView;
          TextView petNameLabel;
          CheckBox ownerCheckBox;
          CheckBox walkerCheckBox;
      }
  
      public void refill(List&lt;ParseObject&gt; pets) {
          mPets.clear();
          mPets.addAll(pets);
          notifyDataSetChanged();
      }
  }
  </code></pre>
  
  <p>Here's the logcat</p>
  
  <pre><code>10-02 01:53:16.412    1270-1270/com.base8.wlkr E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.base8.wlkr, PID: 1270
      java.lang.NullPointerException
              at com.base8.wlkr.adapters.PetWalkerAdapter$1.onClick(PetWalkerAdapter.java:50)
              at android.view.View.performClick(View.java:4438)
              at android.widget.CompoundButton.performClick(CompoundButton.java:100)
              at android.view.View$PerformClick.run(View.java:18422)
              at android.os.Handler.handleCallback(Handler.java:733)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5017)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Please let me know if you need any more information. Any critiques or references are appreciated. Thanks for looking.</p>