Note that there are some explanatory texts on larger screens.

plurals
  1. POBuggy ListView makes me sad
    text
    copied!<p>I have a <code>ListView</code> where I've defined the layout of each item in a separate XML file. In this file I've included a <code>RatingBar</code> and an <code>EditText</code>.</p> <p>I've programmatically created 7-8 items in this <code>ListView</code>. When I scroll through them, it seems to be quite buggy. Here are some examples:</p> <ol> <li><p>If I set focus to the <code>EditText</code> in the first row and then scroll down the <code>ListView</code>, random <code>EditTexts</code> from other rows will have focus. It seems to be that the next <code>EditText</code> after the focused one disappears receives focus. Perhaps this is intentional, but, as a user, it seems very weird.</p></li> <li><p>If I set focus to an <code>EditText</code>, receive a virtual keyboard, type something, and click the "Done" button on my virtual keyboard, the <code>EditText</code> will empty as soon as the virtual keyboard disappears.</p></li> <li><p>Sometimes, when I click an <code>EditText</code>, receive a virtual keyboard and start typing letters, the letters will disappear as soon as I type them.</p></li> <li><p>When I click on an <code>EditText</code>, the virtual keyboard shows itself, but the <code>EditText</code> loses focus and I have to click the <code>EditText</code> again.</p></li> <li><p>Even though I've set the <code>RatingBar</code> to <code>focusable="false"</code>, if I move my scrollwheel, it still grabs focus.</p></li> </ol> <p>One of my problems is all the visible list items get redrawn when I type a character in the virtual keyboard (and since the text of the <code>EditText</code> is set to some data, which is empty, it gets cleared. I don't understand why Android would decide to redraw the list every time I type a character.</p> <p>Here is the XML I'm using to draw them. They are white bubbles, with a gray boarder, and some text, a <code>RatingBar</code> and an <code>EditText</code> inside:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="10dip" android:paddingBottom="10dip" android:paddingLeft="15dip" android:paddingRight="15dip" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="2dip" android:background="@drawable/shape_outer"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="2dip" android:background="@drawable/shape_inner"&gt; &lt;TextView android:id="@+id/rating_category" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/dark_gray" android:textStyle="bold" android:layout_marginBottom="10dip" /&gt; &lt;RatingBar android:id="@+id/rating_rating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numStars="5" android:rating="0" android:stepSize="1" android:focusable="false" android:clickable="false" /&gt; &lt;EditText android:id="@+id/rating_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="1" android:padding="6dip" android:textColor="#000000" android:gravity="left|top" android:lines="3" android:hint="Comment" android:imeOptions="actionDone" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre>
 

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