listview沒法觸發點擊事件的問題

若是一個ListView item中,包含了其它能夠出發點擊事件的widget,例如button , 會發生ListView 沒法觸發 OnItemClickListener 中的onItemClick點擊事件,緣由是由於button搶奪了listview 的焦點。android

解決方法很簡單:在button配置文件中加入屬性:android:focusable="false"spa

        <Buttonorm

            android:id="@+id/btnBuy"事件

            android:layout_width="wrap_content"ip

            android:layout_height="wrap_content"get

            android:layout_alignParentRight="true"it

            android:background="@drawable/btn_normal"配置

            android:layout_marginTop="5dip"List

            android:layout_alignParentBottom="true"方法

            android:text="當即搶購" 

            android:focusable="false"

            android:textColor="@color/white"

            />

相關文章
相關標籤/搜索