Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListView with checkboxes loose checked items when scrolling
    primarykey
    data
    text
    <p>I'm facing with one problem, it's about disappearing checked items in listview when I'm scrolling the list and I don't know what to do.</p> <p>Here is my code of custom adapter:</p> <pre><code>public class SPCKontrola extends Activity { ArrayList&lt;Integer&gt; yourSelectedItems= new ArrayList&lt;Integer&gt;(); @Override public void onResume() { super.onResume(); yourSelectedItems.clear(); } } public class SPCMjereAdapter extends BaseAdapter { private Context context; public SPCMjereAdapter(Context c) { context = c; } public int getCount() { return MyArrList.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = inflater.inflate(R.layout.activity_list_row, null); } TextView txtOpis = (TextView) convertView.findViewById(R.id.ColOpis); txtOpis.setText(MyArrList.get(position).get("OpisMjere") ); TextView txtRbMjere = (TextView) convertView.findViewById(R.id.ColCode); txtRbMjere.setText(MyArrList.get(position).get("RbMjere")); CheckBox Chk = (CheckBox) convertView.findViewById(R.id.ColChk); Chk.setTag(MyArrList.get(position).get("RbMjere")); Chk.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ yourSelectedItems.add(position); }else{ if(yourSelectedItems.contains(position)){ yourSelectedItems.remove((position)); } } } }); return convertView; } } </code></pre> <p>What should I change or add in code? I have found some examples but I can't reuse non of them and implement in my code :/</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.
 

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