开发者

GridView vs. Other layouts for memory game | Android

I'm trying to create a memory game. I've looked at the Android tutorials for GridView and, while it works, it is somewhat difficult to understand and customize. I would like to ask for advice and opinions on what layouts I should use for the memory game I'm working on. It'll be a simple "grid" of pictures and people will be trying to find the matching pairs.

Please provide what you think would be a good layout to use and the advantages/disadvantages of that layout. Layouts such as Gridview, LinearLayout, TableLayout, etc.

Are there any layouts that are simple and easy to customize for my memory game? I'm asking as someone who is new to programming. I have watched an introductory programming video lecture series from Stanford using Java, so I understand the basics of Java but I am not advanced.

More information, just in case you want to know: I initially tried to create the GridView in java and not XML. But for some reason, the GridView wouldn't display on the emulator. It was just a blank screen. I believe it was because I did not have the layout set to MATCH_PARENT. But I don't know how to do that from java. I tried googling it, but I couldn't find an answer. I eventually settled on doing it through XML. If anyone knows how to do it through java, that would be very much appreciated.

I also had difficulty understanding the ImageAdapter class in the GridView tutorial: (http://developer.android.com/resources/tutorials/views/hello-gridview.html). Specifically, I do not 开发者_JAVA百科understand how or when the getView() function is called. It isn't explained in the tutorial.

I was able to get it to work but because I don't understand it very well, I am not sure how much I will be able to customize it for my memory game.

I'm sorry for the long post. My question is mainly about which layout I should use for my memory game. If you can answer the question about creating a GridView in java that displays on the emulator, that would be great.

Thank you for your time.


I wrote a fairly straight-forward tutorial for extending BaseAdapter - which is exactly what you'll want to do.

Define your layout in XML. Use a GridView. Then just write a custom adapter to control what gets displayed in the grid.

http://androidcookbook.com/Recipe.seam?recipeId=588

It's written with a ListView in mind but the same methods will be implemented for a GridView. If that is too advanced you'll need to start with a smaller app and build your understanding from a lower level.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜