i have a checked text view inside of a listview and whenever I click an item in the list view a random checked text view will check (not neccessarily the one I pressed) Here is my code
lv2.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
final CheckedTextView checkedTextView = (CheckedTextView) findViewById(R.id.checkedTextView1);
checkedTextView.toggle();
}
});
Where lv2 is my list view and checkedTextView1 is my check view inside each listview item. How do I call a specific checkedTextView. Is there an array format that I can call? eg checkedTextView[1].toggle();
?
Edit here is my adapter
public class SpecialAdapter2 extends ArrayAdapter<String> {
private int[] colors = new int[] { R.drawable.row_background_grey,
R.drawable.row_background_white };
public SpecialAdapter2(Context context, int resource, String[] names) {
super(context, resource, names);
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
int colorPos = position % colors.length;
view.setBackgroundResource(colors[colorPos]);
return view;
}