Làm cách nào để tắt điểm đánh dấu màu cam khi nhấp vào một mục trong GridView?Android: Tắt đánh dấu trong GridView
Tôi không thể tìm thấy giải pháp trong tài liệu hoặc thông qua thử nghiệm.
Làm cách nào để tắt điểm đánh dấu màu cam khi nhấp vào một mục trong GridView?Android: Tắt đánh dấu trong GridView
Tôi không thể tìm thấy giải pháp trong tài liệu hoặc thông qua thử nghiệm.
Sử dụng android:listSelector="#00000000"
trong phần tử GridView
trong tệp bố cục XML của bạn.
Trên danh sách xem android: listSelector = "@ null" thực hiện thủ thuật nhưng trên GridView không hoạt động. Nhưng đặt nó trong suốt sẽ hoạt động =/ – Warpzit
+1! 50 bên cạnh tôi ... –
Lưu ý rằng các yếu tố của chế độ xem được chọn vẫn có thể thay đổi để phản hồi lại lựa chọn (ví dụ: TextViews thay đổi thành trạng thái màu "đã chọn"). Xem [câu trả lời này] (http://stackoverflow.com/a/3187007/85950) để biết cách tắt hoàn toàn lựa chọn. – blahdiblah
tôi đã làm điều tương tự trong mã sử dụng
GridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
Nó cũng làm việc với twowayGridView – isha
lựa chọn khác là để tham khảo các màu trong suốt qua @android: màu/minh bạch
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@android:color/transparent"
/>
<GridView
android:id="@+id/gridView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:horizontalSpacing="10dp"
android:listSelector="#00000000"
android:numColumns="3"
android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
Xong! đây là một giải pháp. cảm ơn bạn :)
Chỉ cần đặt thuộc tính bên dưới vào tệp XML của bạn.
android:focusableInTouchMode="false"
Thêm khách sạn này để GridView
android:listSelector="@android:color/transparent"
Thêm android:listSelector="#00000000"
hoặc android:listSelector="@android:color/transparent"
trong phần tử XML GridView của bạn như dưới đây.
<GridView
android:id="@+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="150dp"
android:gravity="center"
android:listSelector="#00000000"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" />
Try It ...
android: listSelector = "@ android: màu/minh bạch"
liên quan: "[Disable Android GridView làm nổi bật hoàn toàn (vô hiệu hóa lựa chọn)] (http: // stackoverflow.com/q/3159897) "nếu bạn muốn vô hiệu hóa không chỉ làm nổi bật nhưng lựa chọn và sử dụng GridView chỉ để bố trí, hoặc xử lý lựa chọn bằng tay thông qua onTouch/Click/etc listeners. – blahdiblah