Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I too had the same problem. I solved it using the following method.<br> I created a bean class to set the checked property of checkbox and used <code>ArrayAdapter</code>. The <code>ArrayAdpater</code> extends the bean class.</p> <h1>Bean Class</h1> <pre><code>public class MCSSCheckState { private boolean isChecked; public boolean getIsChecked() { return isChecked; } public void setIsChecked(boolean isChecked) { this.isChecked = isChecked; } } </code></pre> <h1>Java Class</h1> <pre><code>ArrayList&lt;MCSSCheckState&gt; mTitleList = new ArrayList&lt;MCSSCheckState&gt;(); MCSSCheckState check_state=new MCSSCheckState(); check_state.setIsChecked(false); mTitleList.add(i, check_state); ListAdapters adapter = new ListAdapters(this,R.id.camTitleTextView, mTitleList); ListView mListView = (ListView) findViewById(R.id.cameraListView); mListView.setAdapter(adapter); </code></pre> <h1>Adapter Class</h1> <pre><code>private class ListAdapters extends ArrayAdapter&lt;MCSSCheckState&gt; { private ArrayList&lt;MCSSCheckState&gt; items; private int position; public ListAdapters(Context context, int textViewResourceId, ArrayList&lt;MCSSCheckState&gt; mTitleList) { super(context, textViewResourceId, mTitleList); this.items = mTitleList; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; this.position = position; if (v == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = inflater.inflate(R.layout.camerslistinflater, null); } MCSSCheckState o = (MCSSCheckState) items.get(position); if (o != null) { checkBox = (CheckBox) v.findViewById(R.id.checkBox1); checkBox.setTag(position); checkBox.setChecked(o.getIsChecked()); checkBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { MCSSCheckState obj = (MCSSCheckState) items.get(Integer.parseInt(v.getTag().toString())); obj.setIsChecked(((CheckBox)v).isChecked()); items.set(Integer.parseInt(v.getTag().toString()), obj); } }); } return v; }); } </code></pre> <p>Hope this helps you.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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