我应该采取什么方法来制作数个网格?
我正在为 Android 创建一个 Kakuro 游戏,它主要由一个大网格组成,其中仅包含根据图案的黑色和白色方块。我决定使用从 Button
扩展的自定义类来表示黑色和白色方块。
但问题是,我无法弄清楚使用和/或扩展什么来表示包含正方形(包含按钮)的网格。它应该具有以下行为:
- 应该能够沿着 x 轴和 y 轴容纳
Button
。 - 应该可以两种方式滚动,因为网格肯定会超出设备的屏幕尺寸。
- 不应该对内存占用太苛刻。
因此,经过一番思考,我决定创建一个扩展 View
的自定义类。但我不确切知道要重写哪些方法才能获得我想要的行为。
那么谁能告诉我应该重写哪些方法才能获得我需要的行为? (其行为有点类似于扫雷)。
或者我可以使用其他更简单/更快的方法吗?
提前致谢!
I'm creating a Kakuro game for Android and it mainly consists of a large grid which contains only black and white squares according to a pattern. I have decided to use a custom class extended from Button
to represent black and white squares.
But the problem is, I can't figure out what to use and/or extend to represent the square-containing (Button
-containing) grid. It should have the following behavior:
- Should be able to house
Button
s along both x- and y-axes. - Should be scrollable in both ways as the grid will most definitely exceed the device's screen size.
- Should not be too hard on the memory footprint.
So after some thinking, I have decided to create a custom class that extends View
. But I don't know exactly which methods to override to obtain the behavior I want.
So can anyone please tell me which methods I should override to obtain the behavior I need? (The behavior is somewhat similar to that of Minesweeper).
Or is there any other easier/faster method I can use?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它是您想要的网格,我推荐
GridView
。GridView
教程:http://developer.android .com/resources/tutorials/views/hello-gridview.htmlif it is a grid you want, I recommend the
GridView
.GridView
tutorial: http://developer.android.com/resources/tutorials/views/hello-gridview.html扩展 GridView 似乎更适合您的需要: http://developer.android .com/resources/tutorials/views/hello-gridview.html
Extending the GridView seems more suitable for your need: http://developer.android.com/resources/tutorials/views/hello-gridview.html