0

I am trying to get the Checkbox of the first item in a ListView. My code below:

Query recent = databaseRef.limitToLast(5);
FirebaseListAdapter<Item> adapter = new FirebaseListAdapter<Item>(
        this, Item.class, R.layout.custom_list_item, recent

) {
    @Override
    protected void populateView(View view, Item item, int i) {
        ((TextView) view.findViewById(R.id.item)).setText(item.getName());
        ((NumberPicker) view.findViewById(R.id.numberPicker)).setValue(item.getQuantity());
        ((CheckBox) view.findViewById(R.id.checkBox)).setChecked(false);
        ((TextView) view.findViewById(R.id.prosfora)).setText("s" +
                "e prosfora");

         View firstItem = itemLst.getChildAt(0);


    }


};

itemLst.setAdapter(adapter);

I get the first item from the ListView but I don't know how I can get the checkbox from that first item.

Daniel
  • 2,339
  • 9
  • 21
  • 28
ktsakiris
  • 61
  • 1
  • 8

1 Answers1

0

ok. i figured it out myself. i replaced

((CheckBox) view.findViewById(R.id.checkBox)).setChecked(false);

with

CheckBox checkBox_i = (CheckBox) view.findViewById(R.id.checkBox);
checkBox_i.setChecked(false);

then i put a setOnCheckedChangeListener in checkBox_i and i did my "TODO" (actually i wanted all checkboxes not only the first)

ktsakiris
  • 61
  • 1
  • 8