Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to check/uncheck CheckedTextView inside getView
    text
    copied!<p>I'm loading phone contacts in a custom ListView. Each row is a checkable LinearLayout containing a CheckedTextView and another TextView.</p> <p>I'm feeding the list view with a custom ArrayAdapter. My problem is that I can't control CheckedTextViews inside getView(). For example when I try the following</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; if(row == null){ row = inflater.inflate(layout, parent, false); } CheckedTextView checkedTextView = (CheckedTextView) row.findViewById(R.id.checkedTextView); checkedTextView.setText("A"); checkedTextView.setChecked(true); return row; } </code></pre> <p>That's supposed to check every text view whenever I scroll the list view, but that's not happening. Can anybody tell me how to do it?</p> <p>EDIT: It's important to check it inside getView(), I can't just check all after setListAdapter()</p> <p>EDIT2: This is the xml file showing the view of each row</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;com.example.multiplecontacts.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;CheckedTextView android:id="@+id/checkedTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:paddingBottom="0dp" android:text="CheckedTextView" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;TextView android:id="@+id/subTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Small Text" android:paddingTop="0dp" android:textAppearance="?android:attr/textAppearanceSmall" /&gt; &lt;/com.example.multiplecontacts.CheckableLinearLayout&gt; </code></pre> <p>CheckableLinearLayout is a custom layout that extends LinearLayout and implements Checkable as I said before. And I've taken it from <a href="http://tokudu.com/2010/android-checkable-linear-layout/" rel="noreferrer">here</a> </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