ListView Itemはフォーカスの問題を取得できません
通常、focusをデフォルトで取得できるコントロールにはButtonがあり、Checkableが継承したすべてのコントロールがあります.これは、カスタムListViewの中にButtonまたはCheckableのサブクラスコントロールがある場合、デフォルトfocusはサブコントロールに渡され、ListViewのItemが選択できる基礎はFocusを取得できることです.したがって、itemのサブコントロールのfocusはfalseでなければなりません.これにより、itemはonItemClickイベントを取得できません.(RatingBarにはisIndicator属性があり、RatingBarが指示用かどうかはtrueにするべきで、そうでなければ焦点も得られない)
1.
ListViewのItem Layoutのサブコントロールfocusableプロパティをfalseに設定
2.
Item Layoutのルートコントロールandroid:descendantFocusability="blocksDescenendant"
例:
1.
ListViewのItem Layoutのサブコントロールfocusableプロパティをfalseに設定
2.
Item Layoutのルートコントロールandroid:descendantFocusability="blocksDescenendant"
例:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dip"
android:background="#ffffffff"
android:descendantFocusability="blocksDescendant >
<LinearLayout
<RatingBar
android:id="@+id/rb_bookRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rating="2.0"
style="@style/RatingBar"
android:isIndicator="true"
/>
</LinearLayout>
<Button
android:id="@+id/btn_schedule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusable="false"
android:text=" "
style="@style/Button"
/>
</RelativeLayout>