GridView vs. Other layouts for memory game | Android - 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 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.

Related

Information for swapping tiles in a gridview

i'm making an n-puzzle and already have a gridview with one blank image in the bottom-corner in the right. My goal is now to shuffle the images in the gridview and make a game of fifteen. As beginning programmer in android i have little knowledge of the platform and would apreciate tips and tricks or hints of how i must handle this problem.
I already know that the .setTag() command will be very handy for this problem, but can't seem to find informationblogs or sources on how to use it properly and how to handle this problem.
with kind regards,
Kees Til

Scrollview with paging in android

is there a simple/native way to implement paging/pagination on scrollviews?
By simple, I mean with a short piece of code mainly using classes from Android SDK, like, when programming on iPhone, writing "pagingEnabled = YES".
When I was looking for the topic on the Internet, I saw people putting pieces of code about that matter, but these pieces of code were very large, and I can't help myself to believe Google did put a simple way to do it in their SDK. I also think that the code to implement it could be much easier than what I saw when looking for it. I'm currently working on it, but in the meantime, if anyone know a easier way to do it, I would be delighted to know about it.
Thanks for reading!
I think that there is not a fast solution to do this.
But what you can do is to take the gallery component and override the layout. The gallery component has paging :)
Another solution could be:
Horizontal Pager - https://github.com/ysamlan/horizontalpager
Real View Switcher http://marcreichelt.blogspot.com/2010/09/android-use-realviewswitcher-to-switch.html
Hope this helps...

Creating professional GUI for Android application

I want to create professional looking GUI for Android application. Something more than just raw widgets which I'm taught to use in countless tutorials in the web.
Unfortunately, I couldn't find any source of information how to customize those widgets and create better looking GUI.
Examples could be: http://android.appstorm.net/wp-content/uploads/2011/03/calorific-sc.jpg
or http://android.appstorm.net/wp-content/uploads/2011/03/chomp-sc.jpg
How are such GUIs created? If you could point me out to some tutorials on it, I would be really thankful!
Greetings,
Bart
There's nothing in those examples that looks like it couldn't be made from standard components. For instance the second screen of that calorific application is just a background image for the window with a list and a button with a background image as well. The first image could easily be done with just buttons and background images for views as well.
TLDR: Split the view into rectangles, assume that these are all standard components with images as backgrounds unless they seem to have nonstandard interactions.
Those are called custom components.
You will need to do a fair amount of work to get the look you want. (compared to using system components).
http://developer.android.com/guide/topics/ui/custom-components.html
Edit
Bone up on your Google-fu Bart!
http://www.google.com/search?q=custom+components+android+tutorial

Scroll through XML content example

Can someone point me to an Android example with source that allows the user to scroll through the contents of an xml file that contains text entries (preferrably with arrows on the side of the screen that allow previous/next type of interaction)
I've looked through the examples on the Android site and didn't see anything similar. Any help would be GREATLY appreciated (I'm an Android newbie but experienced Java developer)
I seriously doubt you are going to find a nice Android walkthrough of exactly the problem you are trying to solve, so you'll probably need to extrapolate from a few different guides.
Parsing xml is not substantially different from parsing xml anywhere else. This guide talks through the 3 different ways of doing so. Depending on how large your xml is, you can decide which makes the most sense for you.
In terms of UI, not sure exactly what you are looking for, but a ListView is often a good way to display large chunks of data. See Hello ListView.
Or, if you want a single text area that scrolls with 2 buttons, see ScrollView api. Its pretty simple. Common Layout Objects is a good guide to basic layout. You could probably accomplish what you want with a few nested LinearLayouts, or a RelativeLayout. If you post an attempt, people can help you fix it up.

How to build custom grid

I have a problem and i will be grateful if anyoune helps me.
Ok. I've started android programming 2 month ago. Now i am developing a simple game, nava battle. For this programm i need to build a grid, where i can place ships and coordinates. I can't seem to find out how I should be doing this?
I think i should build a custom view, which will do all that i need. If anyone could show some examle or explain how to build appropriate view i'll be happy
IMO you should consider extending or at least using a GridView and place your UI components inside it. The Adapter backing the Gridview could contain information about the co-ordinates and Images(ships).
I think the following would be useful to you:
Beginners tutorial on GridViews
Building custom components
This is an example of board game developed on Android:Chess on Android

Categories

Resources