Search code examples
androidrating

ListView selection problem with rating control?


friends,

i have created very simple custom listview adapter with ratingBar in it.

now i have noticed one thing i cannot rate those rating bars in listview because when i click on listview that row particular row gets selected.

any one guide me how to select individual items in android listview?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ListView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/android:list"
    />
</LinearLayout>

and listview_item design

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:orientation="horizontal"
  android:layout_height="wrap_content">
  <LinearLayout
  android:layout_width="265dip"
  android:orientation="vertical"
  android:layout_height="wrap_content">
  <TextView android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:id="@+id/text1"
  android:textSize="25dip"
  android:text="This is text1"/>
  <TextView android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:id="@+id/text2"
  android:text="This is text2"/>
  <RatingBar android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  style="?android:attr/ratingBarStyleSmall"
  android:id="@+id/star"
  android:numStars="10"
  android:stepSize="0.1"
  android:isIndicator="true"
  />
  </LinearLayout>
 </LinearLayout>

any help would be appreciated.


Solution

  • android:isIndicator="false" in order to rate it. and listview selection will be gone automatically and control will be transferred to that rating control.