2

ListView の TableRow に RatingBar があるonListItemClick場合、行に触れても発生しません。コントロールを実行するbar.setVisibility(View.GONE)か、単に削除すると、行は再びクリック可能になります。

RatingBar を追加したときに、その行が引き続き発生するようにするにはどうすればよいonListItemClickですか? を設定してみましたfocusable="false"が、それでもうまくいきません。

アイデア????

TableRow の RatingBar の XML は次のとおりです。

<TableRow
            android:id="@+id/tableRow2x"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

            <RatingBar 
      android:id="@+id/rtbProductRating"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:numStars="5"
      android:rating="3.5"
      android:layout_marginLeft="8dip"
      android:layout_marginTop="3dp"
      android:layout_marginBottom="3dp"
      android:isIndicator="false"
      android:focusable="false"
      android:focusableInTouchMode="false"
      style="@style/starRatingBar"  
/>  

            </LinearLayout>

        </TableRow>

そして、ここに私のコードがあります:

public class MainFragment extends ListFragment {

    public void onListItemClick(ListView parent, View v, int position, long id)
    {
        //... does stuff
    }
4

2 に答える 2

1

onClick イベントは RatingBar によってインターセプトされているため、onListItemClick は発生しません。

RatingBar クラスを拡張し、onTouchEvent メソッドをオーバーライドして、false を返すことができます。

@Override
public boolean onTouchEvent(MotionEvent event) {
    super.onTouchEvent(MotionEvent event)
    return false;
}
于 2012-07-28T02:01:46.503 に答える
0

RatingBar をこれに設定すると、問題の ratingBar.setIsIndicator(true); が修正されます。

于 2015-05-21T13:34:53.207 に答える