我想实现一个场景-屏幕顶部有一个复选框,并且在该顶部复选框下方有一个带有复选框的自定义列表视图。
我希望有人检查该复选框,所有列表视图复选框都应该被选中,反之亦然。
public class GroupMemberListAdapter extends BaseAdapter {
private LayoutInflater inflater = null;
Context Mycontext;
public GroupMemberListAdapter(Context context) {
Mycontext = context;
inflater = LayoutInflater.from(context);
}
public int getCount() {
return broadcastList.size();
}
public Object getItem(int paramInt) {
return paramInt;
}
public long getItemId(int paramInt) {
return paramInt;
}
public View getView(int position, View convertView, ViewGroup parent) {
EventViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.contactcustomlayout,
null);
holder = new EventViewHolder();
holder.mtvGroupMemberName = (TextView) convertView
.findViewById(R.id.tvGroupMemberName);
holder.checkbox_group_member = (CheckBox)convertView.findViewById(R.id.checkBox_GroupMember);
/*holder.mtvGroupMemberAbout = (TextView) convertView
.findViewById(R.id.tvGroupMemberAbout);*/
convertView.setTag(holder);
} else {
holder = (EventViewHolder) convertView.getTag();
}
holder.mtvGroupMemberName.setText(""+broadcastList.get(position));
//holder.mtvGroupMemberAbout.setText(""+data.get(position));
return convertView;
}
public class EventViewHolder {
private TextView mtvGroupMemberName;
private TextView mtvGroupMemberAbout;
private CheckBox checkbox_group_member;
}
}
checkBox_selectAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
checkAllBoxes();
}
});
private void checkAllBoxes(){
int size = mlvGroupBroadContact.getAdapter().getCount();
System.out.println("Size of the list is:"+size);
}
如何检查所有列表视图框???