title: Problems with finding position in Adapter for ListView
body: <p>I am having some serious trouble with getView in a ListView. The problem is, that I have CheckBoxes on each row. I need to work with them - the ListView is part of TabHost and I need to remember which CheckBox was checked and use it in other tabs.</p>
  
  <p>However, I also have a "master checkbox" that checks all of the checkboxes in the listview. No big deal, but the thing is, that I just can't find out where I clicked to change the state of the CheckBox in ArrayList, where I keep all the states of the CheckBoxes. Everytime I assign listener to every View, the "int position" as an argument gives some weird number, definitely not the one I need - the position in the adapter, I bet it's something like "position on the screen right now..."</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
          count = position;
          View rowView = convertView;
          SingleCarView sView = null;
  
          if (rowView == null) {
              LayoutInflater inflater = activity.getLayoutInflater();
              rowView = inflater.inflate(R.layout.activity_overview_listview_row, null);
              sView = new SingleCarView();
  
              sView.cbx = (CheckBox)rowView.findViewById(R.id.overview_listview_chckbox);
              sView.carName = (TextView)rowView.findViewById(R.id.overview_listview_label);
              sView.state = (ImageView)rowView.findViewById(R.id.overview_listview_icon);
              rowView.setTag(sView);
          } else {
              sView = (SingleCarView) rowView.getTag();
          }
          // THE TROUBLE BEGINS HERE...
          sView.cbx.setChecked(savedState.get(position));
          sView.cbx.setOnCheckedChangeListener(new OnCheckedChangeListener() {
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                  if(computerActionWithCheckBox) {
                      // nothing
                  } else {
                      if(allCars.isChecked()) {
                          savedState.set(count, isChecked);
                          userModifiedCheckBox = true;
                          allCars.setChecked(false);
  
                          adapter.notifyDataSetChanged();
                      } else {
                          savedState.set(count, isChecked);
                      }
                  }
              }
          });
          sView.carName.setText(objects.get(position));
          switch(DataLoaderBeta.par.carState.get(position)){
          case 1:
              sView.state.setImageResource(R.drawable.ic_moving);
              break;
          case 2:
              sView.state.setImageResource(R.drawable.ic_out_of_signal);
              break;
          case 0:
              sView.state.setImageResource(R.drawable.ic_parked);
              break;
          }
          return rowView;
      }
  </code></pre>
  
  <p>Thanks a lot for any answer! :-)</p>