Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you look at your code more attentively, concretely on the <code>getView()</code>, you'll see that you create <code>ViewHolder</code> object every time independently of <code>convertView</code> presence. </p> <p>This is wrong using of <code>ViewHolder</code> pattern. Instead of creating it everytime, create it only when <code>convertView</code> is null and set it as the tag of <code>convertView</code> by <code>setTag()</code>, otherwise get the reference to <code>ViewHolder</code> using <code>getTag()</code>. Just Like this:</p> <pre><code> ViewHolder viewHolder; if (paramView == null) { paramView = mInflater.inflate(R.layout.multiplecontactview, null); viewHolder = new ViewHolder(); viewHolder.tvName = (TextView) paramView.findViewById(R.id.txtContactName); viewHolder.tvNumber = (TextView) paramView.findViewById(R.id.txtContactNumber); viewHolder.cb = (CheckBox) paramView.findViewById(R.id.checkBox1); paramView.setTag(viewHolder); } else { viewHolder = (ViewHolder) paramView.getTag(); } viewHolder.cb.setTag(paramInt); viewHolder.cb.setChecked(mSparseBooleanArray.get(paramInt)); viewHolder.cb.setOnCheckedChangeListener(mCheckedChangeListener); viewHolder.tvName.setTextColor(Color.BLACK); viewHolder.tvNumber.setTextColor(Color.BLACK); for (int i = 0; i &lt; mAdapData.size(); i++) { Map&lt;String, String&gt; map = (Map&lt;String, String&gt;) mAdapData.get(paramInt); final String name = map.get("Name").toString(); final String numbr = map.get("Phone").toString(); viewHolder.tvName.setText(name); viewHolder.tvNumber.setText(numbr); } return paramView; </code></pre> <p>Also in your <code>preformFiltering()</code> try to change this snippet:</p> <p><code>if (names.toLowerCase().contains(cs))</code> </p> <p>to</p> <p><code>if (names.toLowerCase().contains(cs.toString().toLowerCase()))</code> </p> <h1>Update</h1> <p>There is some strange snippet of code:</p> <pre><code>OnCheckedChangeListener mCheckedChangeListener = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mSparseBooleanArray.put((Integer) buttonView.getTag(), isChecked); } }; </code></pre> <p>It means that if you first time check the list item which is on the 0 position in the list, than <code>SparseArray</code> indicates that the first item of the <code>ListView</code> should always have a checked box, because you don't uncheck it anywhere in you code, don't set the value to false but do it only when user manually uncheck the checkbox.</p>
 

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