2011-09-26 30 views
12

Tôi đang thêm một số chế độ xem Linearlayout trong chế độ xem cuộn phim bằng cách tăng cường động chúng. Tôi đã thiết lập nền của LinearLayout được thêm vào danh sách chọn. Nhưng sau khi thêm vào scrollview, khi tôi nhấn xem được chọn, nó không hiển thị bất kỳ ảnh hưởng nào của danh sách chọn. Ví dụ XMLs Tôi đang sử dụng là: tập tinbộ chọn nền linearlayout android

Selector: selector_file

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/listbg" 
     android:state_pressed="true" /> 
<item android:drawable="@drawable/bgsmall"/> 
</selector> 

Và tôi lạm phát quan điểm sau đây và thêm vào L1 LinearLayout:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/selector_file" 
android:gravity="center_vertical" 
> 
<ImageView android:id="@+id/image1" android:layout_width="100dip" android:layout_height="75dip"/> 
<TextView android:id="@+id/textitem" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000"></TextView> 
</LinearLayout> 

Và scrollview mà trên lượt xem tăng cao đang được thêm vào là:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
> 

<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> 
    <LinearLayout android:id="@+id/l1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> 

</LinearLayout> 
</ScrollView> 
</LinearLayout> 

Bất kỳ ý tưởng nào ... ???

+0

có hoạt động nếu bạn đặt nó bên ngoài chế độ xem cuộn? – blessenm

+0

Tôi đoán một số điều khiển trong scrollview tiêu thụ sự kiện đã nhấn để con bạn LinearLayout không thể liên lạc được. – anticafe

+1

Thực ra tôi đang thiết lập bộ chọn cho nền của Linearlayout. Nếu tôi sử dụng cùng một bộ chọn cho một nút, nó hoạt động nhưng không cho LinearLayout ... –

Trả lời

28

Bạn phải thực hiện LinearLayout có thể nhấp.

android:clickable="true" 
+0

Cảm ơn rất nhiều, tôi đã bỏ lỡ để đặt trong bố cục tương đối – Zoombie

Các vấn đề liên quan