本文介绍了如何从Android版的ListView复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
荫使用下面的代码片段正从OnItemClickListener复选框
Iam getting Checkbox from OnItemClickListener by using below snippet
onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.w("TAG","onItemClick clicked position :"+position);
CheckBox cbx = (CheckBox)view.findViewById(R.id.c_checkbox);
if(cbx.isChecked()){
Toast.makeText(getApplicationContext(),
"Checked position " + shoppingList.get(position).getItem(),
Toast.LENGTH_SHORT).show();
}
我需要让所有的位置检查哪个列表项是checked.For的
我用下面的代码片段
I need to get all the positions to check which list item is checked.For thatI used below snippet
int firstPosition = list.getFirstVisiblePosition();
for(int i=firstPosition;i<=list.getCount();i++){
View v=list.getChildAt(i);
cbx = (CheckBox)v.findViewById(R.id.c_checkbox);
if(cbx.isChecked()){
}
}
在下面code CBX给我exception.i使用ViewHolder自定义空指针adapter.Please给我solution.why同样的事情在OnItemClickListener工作?
in below code cbx giving me null pointer exception.i used ViewHolder for the custom adapter.Please give me solution.why same thing is worked in OnItemClickListener?
问候,
Rajendar
Regards,Rajendar
推荐答案
它认为它可能是
for(int i=firstPosition;i< **=** list.getCount();i++)
但也只是胡乱猜测。
but that is just a wild guess.
为什么不使用一个可检查的列表视图,然后使用this?
why not use a checkable listview and then use this?
这篇关于如何从Android版的ListView复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!