有人可以告诉我如何使用复选框更改Android中listview中的项目大小吗?
取消选中该复选框后,listview中的项目将是正常大小。
选中该复选框后,列表视图中的所有项目都会放大。
代码或提示会有所帮助,谢谢
答案 0 :(得分:0)
这是用于根据复选框状态在适配器的getview中检查和设置listview项目大小。
if(!isChecked)
{
convertView.setLayoutParams(new ListView.LayoutParams(NormalWidth,
Normalheight));
}
else
{
convertView.setLayoutParams(new ListView.LayoutParams(EnlargeWidth,
Enlargeheight));
}
并且对于复选框选中的更改,您可以按如下方式编写:
mCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
this.isChecked = isChecked;
adapter.notifyDataSetChanged(); /* this line will Refress the listview so you can change the value of isChecked variable then it will change the size of listview item.*/
}
});