现在是时候为我探索 Android 了。我设计了一个如下所示的 ui,问题是我对在第一帧中应该做什么以获得 9x9 网格感到困惑。实际上,我通过使用 for 循环在每个单元格中放置 81 个 JTextFields 并在 gridbaglayout 的帮助下在核心 java 中开发了同样的东西,并且我的应用程序完美运行。但是在 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>
这是用户界面
.