I have a ListView where I defined the layout of each element in a separate XML file. In this file, I have included RatingBar and EditText .
I programmatically created 7-8 items in this ListView . When I scroll through them, it seems like it's pretty buggy. Here are some examples:
If I set the focus on EditText in the first row, and then scroll down the ListView , random EditTexts from other rows will have focus. It looks like the next EditText after the focused one disappears, gets the focus. Perhaps this is intentional, but as a user, it seems very strange.
If I set focus on EditText , get a virtual keyboard, type something and click the Finish button on my virtual keyboard, EditText will be empty as soon as the virtual keyboard disappears.
Sometimes, when I click EditText , I get a virtual keyboard and start typing letters, the letters disappear as soon as I type them.
When I click on EditText , the virtual keyboard shows itself, but EditText loses focus, and I need to click EditText again.
Even if I set the RatingBar to focusable="false" , if I move my scroll wheel, it still captures the focus.
One of my problems is that all the visible elements of the list get redrawn when I type in the character on the virtual keyboard (and since the EditText set to some data that is empty, it is cleared. I donβt understand why Android decides to redraw the list each time the character is entered.
Here is the XML that I use to draw them. These are white bubbles with a gray border and some text, RatingBar and EditText inside:
<?xml version="1.0" encoding="utf-8"?> <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" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="2dip" android:background="@drawable/shape_outer"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="2dip" android:background="@drawable/shape_inner"> <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" /> <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" /> <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" /> </LinearLayout> </LinearLayout> </LinearLayout>
android listview listviewitem virtual-keyboard
Andrew Aug 12 '10 at 14:29 2010-08-12 14:29
source share