我使用自定义背景网格项目,并作为正常的它工作,但是当我做点击任何网格项目(它不工作)GridView控件高亮所选项目
那么可能是什么原因,为什么当我在任何网格项目做点击它不工作,而其在正常模式下工作..
对于ImageGallery我使用this教程,并强调网格项下this一个
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/blue" android:state_pressed="true" />
<item android:drawable="@color/blue" android:state_selected="true" />
<item android:drawable="@color/blue" android:state_focused="true" />
<item android:drawable="@color/white" />
</selector>
网项目布局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/grid_background"
android:descendantFocusability="blocksDescendants"
android:padding="5dp">
<ImageView
android:id="@+id/grid_item_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop">
</ImageView>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="1dip" >
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
</RelativeLayout>
这里是主电网的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">
<!-- The GridView to display picture's preview -->
<GridView
android:id="@+id/grid_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:gravity="center"
android:stretchMode="columnWidth"
android:drawSelectorOnTop="true"
android:focusable="true"
android:clickable="true"
android:scrollbars="none"
>
</GridView>
</RelativeLayout>
这就是我得到正常的,甚至当我做任何GridView的项目的挖掘:
selector.xml
然后里面的GridView添加的XML删除背景并尝试Gridview中'android:listSelector'中的选择器。 – Harry