Question: Implement Section ListView with Checkbox?

Question

Implement Section ListView with Checkbox?

Answers 1
Added at 2017-01-02 10:01
Tags
Question

I need section Listview with checkbox and every row have some have I need total of selected row. Here I have used Recyclerview due to Lazy Loading I have to used Listview. enter image description here

List view have 10 member in Array List but initially i am getting only 4 row value i need 10 at initially.This happen due to Lazy Loading.

Thanks's in advance

Answers to

Implement Section ListView with Checkbox?

nr: #1 dodano: 2017-01-02 10:01

You can implement a Custom interface in your Adapter. When you checked your item from list you have to pass the result to your Activity and later you can make sum of it.

interface CheckItemList{

        public void onCheckItem(int value){}

    }

In your Adapter Class create a reference of Interface and call onCheckItem()

CheckItemList checkItemList = (CheckItemList) mContext;

satView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

       @Override
       public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
              if(isChecked){
       checkItemList.onCheckItem(value);
         }
       }
   }
); 

Implement CheckItemList interface in your activity or some singleton class.

class MyActivity extends Activity implements CheckItemList.
  onCheckItem(int value){
  //Add your code to store checked value  
}

}

Source Show
◀ Wstecz