1. 程式人生 > >Android listview子控制元件的的點選事件(轉)

Android listview子控制元件的的點選事件(轉)

1.先看圖,是否是你想要的

 


2.佈局檔案
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lin_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants"----------------//加上這行
>

<ListView
android:id="@+id/hot_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="#00000000"
android:listSelector="#00000000"
></ListView>

</LinearLayout>

descendantFocusability屬性的值有三種:
beforeDescendants:viewgroup會優先其子類控制元件而獲取到焦點

      afterDescendants:viewgroup只有當其子類控制元件不需要獲取焦點時才獲取焦點

      blocksDescendants:viewgroup會覆蓋子類控制元件而直接獲得焦點

子控制元件設定:android:focusable="false"
---------------------
作者:富貴程式設計之路
來源:CSDN
原文:https://blog.csdn.net/zcf520android/article/details/51471018
版權宣告:本文為博主原創文章,轉載請附上博文連結!