gpt4 book ai didi

android - 如何在android中获得9x9网格的显示?

转载 作者:太空狗 更新时间:2023-10-29 15:36:49 25 4
gpt4 key购买 nike

现在是时候为我探索 Android 了。我设计了一个如下所示的用户界面,问题是我对在第一帧中应该做什么以获得 9x9 网格感到困惑。实际上,我在核心 java 中开发了同样的东西,通过使用 for 循环在每个单元格中放置 81 个 JTextFields 并在 gridbaglayout 的帮助下,我让我的应用程序完美运行。但是在 android 中,我如何在 xml 中定义我的 9x9 单元格,以便它应该接受数字并且也应该检索输入的数字以验证数独规则。以下是我的代码和图表。谁能建议如何使框架 1 具有 9x9 单元格?如果我在我的 xml 文件中使用 TextEdit,它将是 81 个文本字段,如果我使用 Canvas(我在想,不知道是否可能),在我看来似乎不可能让它接受数字并从中检索 Canvas 板。如果有人能提供帮助,我真的很感激。请放轻松,如果这个问题看起来很愚蠢(我希望不会,因为我已经尝试了 2 天),因为我是 android 的新手。提前致谢。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#0f0"
/>
<FrameLayout
android:id="@+id/fLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="#00f">

<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keypad"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">

<TableRow >
<Button android:id="@+id/cancel"
android:text="cancel"
android:layout_span="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</TableRow>
<TableRow>
<Button android:id="@+id/submit"
android:text="validate"
android:layout_span="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

</Button>
</TableRow>
</TableLayout>

</FrameLayout>
</LinearLayout>

这是界面

enter image description here .

最佳答案

查看来自 Git Hub 的这个开放式数独项目.在这里您可以找到数独的布局和源代码。

检查数独 View 的 res/layout/sudoku_edit.xml

关于android - 如何在android中获得9x9网格的显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12140558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com