如何在android中显示9x9网格?

Kan*_*nth 2 grid user-interface android cell

现在是时候为我探索Android了.我设计了一个ui,如下所示,事情是我对第一帧中应该做什么感到困惑,以获得9x9网格.实际上,我在核心java中开发了同样的东西,通过使用for循环在每个单元格中放置81个JTextFields并且在gridbaglayout的帮助下,我的应用程序完全正常工作.但是在android中如何在xml中定义我的9x9单元格,因此它应该接受数字并输入数字也应该被检索以验证数独规则.以下是我的代码和图表.任何人都可以建议如何使帧1有9x9细胞?如果我在我的xml文件中使用TextEdit,它将是81个文本字段,如果我使用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>
Run Code Online (Sandbox Code Playgroud)

这是UI

在此输入图像描述.

Chi*_*rag 5

Git Hub看这个Open Sudoku项目.在这里,您可以找到Sudoku的布局和源代码.

检查数据 视图的res/layout/sudoku_edit.xml.