Note that there are some explanatory texts on larger screens.

plurals
  1. POconvertView loses onitemClick after the listView is scrolled
    primarykey
    data
    text
    <p>I'm having a slightly weird error here on my adapter. The view the adapter is creating is a thumbnail on the left side and a table with a few rows. Each row have two textviews.</p> <p>One of the textviews have the <code>android:autoLink="web"</code> property set and the listview have an onItemClickListener on it.</p> <p>the problem is that every time a TextView auto-links it's content, next time its parent view is converted, it doesn't receive clicks from the onItemClickListener anymore.</p> <p>Let me clarify with an example:</p> <ul> <li>view1, view2, view3 and view4 are on the list view on the screen.</li> <li>view2 have a link and it appears, and onClick the link opens.</li> <li>the item click works normally for view1, view 3 and view4.</li> <li>scroll the listview and view1 is converted to position5 and then view2 is converted to position6.</li> <li>the item at position6 does not contain a link, but the onItemClick is also not fired for the position6 element.</li> </ul> <p>the autolink feature of the textview is certainly changing something with my layout, but I don't know what. There must a property I can reset for every call to getView on my adapter, but which?</p> <p>thanks for any help.</p> <p><strong>edit</strong></p> <p>let's see some code, it's pretty standard/good practices. the getView from my adapter is: @Override public View getView(int position, View convertView, ViewGroup parent) {</p> <pre><code> // Inflate a new layout if needed if (convertView == null) convertView = createNewView(); // Gets the item from my array AGplus item = (AGplus) getItem(position); // Gets the holder pointing to the views Holder h = (Holder) convertView.getTag(); // That's a test version, I won't be using date.toString() later on h.date.setText(new Date(item.getDate()).toString()); // This guys is giving me a headache, // If it parses the link, I can't never click on this convertView anymore, // event re-converting them for a text that does not contain links h.txt.setText(item.getTitle()); // some image download stuff that doesn't matter for this code return convertView; } </code></pre> <p>that layouts used is a image and table and the amount of rows I inflate and insert on the table varies for each adapter. The table layout is a horizontal linear layout with a imageview and the table layout with some margin stuff and here is the row layout:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TableRow xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="@color/text" /&gt; &lt;TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="web" android:text="" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="@color/text" /&gt; &lt;/TableRow&gt; </code></pre> <p>if I completely remove the <code>android:autoLink="web"</code> I get all the clicks, but as stated before, once a view gets "auto-linked" and then I recycle that view, I can't get clicks on that view again.</p> <p><strong>edit</strong></p> <p>and here is the layout inflation:</p> <pre><code> private View createNewView() { // Instantiate view View v = getLayoutInflater().inflate(R.layout.expandable_child_view, null); TableLayout table = (TableLayout) v.findViewById(R.id.table); Holder h = new Holder(); v.setTag(h); // Instantiate rows h.thumb = (ImageView) v.findViewById(R.id.img); h.date = (TextView) createNewRow(table, "Date: "); h.txt = (TextView) createNewRow(table, "Text: "); return v; } private View createNewRow(ViewGroup group, String title) { View row; row = getLayoutInflater().inflate(R.layout.item_table_row, null); ((TextView) row.findViewById(R.id.title)).setText(title); group.addView(row); return row.findViewById(R.id.text); } </code></pre> <p>and before someone else asks, that's the expandable_child_view layout:</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frame" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" &gt; &lt;ImageView android:id="@+id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:layout_marginLeft="40dp" android:layout_marginRight="5dp" android:layout_marginTop="20dp" android:src="@drawable/ic_launcher" /&gt; &lt;TableLayout android:id="@+id/table" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;/TableLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>as I said before, just a linear layout with a imageview and a table and a few margins.</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