许多 GridView 一起放在一个relativelayout中
我开发了一个Android应用程序来解决“魔方”。首先将从立方体的每一面扫描立方体。颜色识别后,新的活动开始并在 2D 模型中显示结果。这在很多 GridView 中都是实现的。对于每一侧我都有一个 GridView。
现在我的问题是:我已将每个 Gridview 设置为可点击,但只有其中三个可点击。 有效的网格是第一个中间有白色面的网格,中间有蓝色面的网格和中间有黄色面的网格。所有其他网格都不可点击,但为什么呢?我需要它为每个 GridView 实现 OnItemClickListeners,以便在必要时纠正颜色。
我的 XML 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewU"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:focusable="true"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewF"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
</RelativeLayout>
谁能帮助我吗?谢谢...
[编辑] 我已经解决了我的问题。现在我使用 AbsoluteLayout 为每个 GridView 提供固定坐标。
I developing an Android App to solve the "Rubiks Cube". First the Cube will be scanned from each side of the Cube. After color recognition a new activity starts and show the result in a 2D-model. This is realized in much GridViews. For each side i have one GridView.
Now my problem: I've set each Gridview clickable but only three of them are clickable.
The Grids wich works are the first with the white facelet in the middle, the Grid with the blue facelet in the middle and the Grid with the yellow facelet in the middle. All the other Grids are not clickable, but why? I need it to implement the OnItemClickListeners for each GridView so if necessary to correct a color.
My XML File looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewU"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:focusable="true"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewF"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridviewR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="5dp"
android:horizontalSpacing="1dp"
android:columnWidth="28dp"
android:gravity="center"
android:layout_below="@id/gridviewU"
/>
</RelativeLayout>
Can anyone help me? Thanks...
[EDIT]
I've solved my problem. Now i use an AbsoluteLayout with fix coordinates for each GridView.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。请参阅上面的编辑行。
Problem is solved. See the EDIT-line above.