Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting all checkboxes of listview in android
    primarykey
    data
    text
    <p>i am having custom arrayadapter for listview, which has 5 views inside including checkbox, here i want to implement the select all checkboxes of listview and deselect all checkboxes, i tried with <code>getchildat()</code> method in the <code>oncreate()</code>, <code>onresume()</code>, and <code>onpostcreate</code> also but does not made luck to me. i appreciate if you can tell me the solution.</p> <pre><code>@Override public void onPostCreate(Bundle savedInstanceState){ super.onPostCreate(savedInstanceState); Button selectall=(Button) findViewById(R.id.allselect); selectall.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int count = listview.getCount(); System.out.println("the count is "+count); for (int i = 0; i &lt; listview.getLastVisiblePosition() - listview.getFirstVisiblePosition(); i++) { RelativeLayout itemLayout = (RelativeLayout)listview.getChildAt(i); CheckBox cb = (CheckBox)itemLayout.findViewById(R.id.chkbx); cb.setChecked(true); } } }); } </code></pre> <p>Arrayadapter class</p> <pre><code>@SuppressWarnings("unchecked") public MultipleLeadSyncAdapter(Context context, String[] values,String[] values1,List&lt;Model&gt; qrcode ,String[] values3,String[] values4,String[] values5) { super(context, R.layout.multipleselectlist, values1); this.context = context; this.values = values; this.values1 = values1; this.list=qrcode; this.values3=values3; this.values4=values4; this.eventid=values5; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewHolder holder =null; if (convertView == null) { convertView = inflater.inflate(R.layout.multipleselectlist, parent, false); holder = new ViewHolder(); holder.textView1 = (TextView) convertView.findViewById(R.id.multileadfirst_name); holder.textView3 = (TextView) convertView .findViewById(R.id.multileadcompany_name); holder.rate=(RatingBar) convertView.findViewById(R.id.multileadlistrating); holder.chkbox = (CheckBox) convertView.findViewById(R.id.chkbx); holder.chkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { int getPosition = (Integer) buttonView.getTag(); list.get(getPosition).setSelected(buttonView.isChecked()); } }); convertView.setTag(holder); convertView.setTag(R.id.chkbx,holder.chkbox); convertView.setTag(R.id.multileadfirst_name,holder.textView1); convertView.setTag(R.id.multileadcompany_name,holder.textView3); convertView.setTag(R.id.multileadlistrating,holder.rate); }else { holder = (ViewHolder) convertView.getTag(); } holder = (ViewHolder) convertView.getTag(); holder.textView1.setText(values[position]); if(values3[position].equals(" ")||values3[position].equals("null")||values3[position].equals("")){ }else{ String[] temp=values3[position].split(" "); } holder.textView3.setText(values1[position]); holder.rate.setRating(Float.valueOf(values4[position]).floatValue()); String s = values[position]; String ss = values1[position]; System.out.println(s + ss ); holder.chkbox.setTag(position); //holder.textView3.setText(list.get(position).getName()); holder.chkbox.setChecked(list.get(position).isSelected()); String igurl=values[position]; System.out.println("the imagurl is "+igurl); return convertView; } class ViewHolder { String qrcode,Boothid; TextView textView1, textView2, textView3,textView4,textView5; RatingBar rate; ImageView imageView; CheckBox chkbox; public String getQrcode() { return qrcode; } public void setQrcode(String qrcode) { this.qrcode = qrcode; } public String getBoothID() { return Boothid; } public void setBoothID(String Boothid) { this.Boothid = Boothid; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload