How to build custom grid - android

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

Related

How To Make List Of Fragments In Android Programmatically?

I'm working on an Android application and one of the features is a list of upcoming events. I need to be able to generate a 'card' so to speak for each of these events and place them in to a scroll view. This would be simple if I knew how many there were going to be and could prepopulate an axml file but I must populate the scrollview programmatically based off the parse of an xml file on the web so that the client can keep it updated. I've searched everything I can think and the best I can find is a custom list view which I do not think will provide the results needed. I've uploaded an example of what I'm trying to do to my google drive and linked to it below. I should also mention my background is completely C# and I've only been working with java for the last two weeks or so, so if anyone could provide a working code example I would be most appreciative.
https://drive.google.com/file/d/0B8alYNlu3SuoSEk0bE55cDhXWVE/view?usp=sharing
I think that basically what you need to do is to implement a RecyclerView using a LinearLayoutManager (this would represent basically a list) with CardViews as the items or just regular layouts designed by you, the CardView will just make your life easier if you need the Material Design cards appearance.
You have many different tutorials as how to implement this, as you can see here:
http://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156
You'll see there that it's exactly what you need but with smaller Cards.
Let me know if this helps.

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

How to do "android drawing pattern to unlock" using COCOS2D API

I want to do a task which is very similar to "Android Drawing Pattern to Unlock", where in there will be circular images in a GridView and straight lines connecting the images will be drawn dynamically based on user touch. Please suggest me preferably with code snippets.TIA.
Actully, you didn't write your code into the question .so I think you are developing Android Application with COCOS2D first time.
Here is some awesome example links that may Help you to learn this.
1)COCOS2D Basic Game
2)COCOS2D MUltiplatform
If you want help regarding code please post your code here.

Titanium appcelerator Android Drill down

I am having difficulties to find a way to drill down my tableview created for Android. I have 2 or 3 levels of data and I see its not working the same way as for iOS so my question is how the hell to implement drill down for Android?
I heard it should be done with views or something similar. Maybe someone could show an example of passing from one row to another list of data changing window or content of current window?^
thank you.

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 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.

Categories

Resources