问题描述
我需要带有复选框的 Listview
部分,并且每行都有一些我需要选定行的总数。由于延迟加载,我使用 Recyclerview
我必须使用 Listview
。
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
.
列表视图在数组列表中有10个成员但最初我只得到4行值我需要最初是10.这是由于延迟加载而发生的。
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.
提前谢谢
推荐答案
您可以在适配器中实现自定义界面。当您从列表中检查项目时,您必须将结果传递给您的活动,稍后您可以对其进行总结。
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){}
}
CheckItemList checkItemList = (CheckItemList) mContext;
satView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
if(isChecked){
checkItemList.onCheckItem(value);
}
}
}
);
在您的活动或某些单件类中实现CheckItemList接口。
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
}
}
这篇关于使用Checkbox实现Section ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!