我正在使用自定义背景来设置网格项,正常情况下它是有效的,但是当我单击任何一个网格项时(它不起作用)。
那么可能的原因是什么,在正常模式下可以工作,但在单击任何一个网格项时却无法工作。
对于ImageGallery,我正在使用这个教程,并使用这个来突出显示网格项。
那么可能的原因是什么,在正常模式下可以工作,但在单击任何一个网格项时却无法工作。
对于ImageGallery,我正在使用这个教程,并使用这个来突出显示网格项。
<?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中的任意一个项目: