Note that there are some explanatory texts on larger screens.

plurals
  1. POListView with custom ArrayAdapter
    primarykey
    data
    text
    <p>I have a class for the row, it extends <code>RelativeLayout</code> and inflates some layout to self. A <code>CheckBox</code> checked state listener is also set.</p> <pre><code>public class LayersListRow extends RelativeLayout { public LayersListRow (Context context, final GITuple tuple) { super(context); LayoutInflater.from(context).inflate(R.layout.layers_list_item, this, true); ... CheckBox checkbox = (CheckBox)findViewById(R.id.layers_list_item_switch); checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged (CompoundButton buttonView, boolean isChecked) { ... } }); } ... } </code></pre> <p>I have a custom <code>ArrayAdapter</code>, which is filled with some objects of this class. I want to use them as the view too.</p> <pre><code>public class LayersAdapter extends ArrayAdapter&lt;LayersListRow&gt; { @Override public View getView (int position, View convertView, ViewGroup parent) { return getItem(position); } public LayersAdapter (Context context, int resource, int textViewResourceId) { super(context, resource, textViewResourceId); } } </code></pre> <p>But when I set this adapter to my <code>ListView</code> the <code>CheckBox</code>'s listener doesn't work. But for the items which appears on scroll down, it works fine. </p> <p>If I replace <code>return getItem(position);</code> in the <code>getView</code> method with</p> <pre><code>if (null == convertView) return getItem(position); return convertedView; </code></pre> <p>then for all items visible at first in the list listener works great, but when I try to scroll I get wrong item (the first one again), <code>ListView</code> freezes and don't respond.</p> <p>Why is this happening and how should I make it work properly?</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