This is a very simple card memory game I wrote for Android platform.
I’ve attached it complete with source code and resources.
Enjoy.


zip  Download Game

zip  Download Source code



Screen shots:





 

34 Responses to “Memory Game – Android Application”

  1. mitu says:

    androidmenifest.xml is missing in source code

    • admin says:

      Are you sure?
      I have just download the source code and saw it.
      Please check again.
      If there is still a problem, leave me your email and I will send it to you.

      • Mitu says:

        Hi,

        I tried to download a source code and build the game but it gives
        the same error. Can you please email me zipped folder ?

        Thanks,

        Mitu

      • Jinka says:

        Hi, i downloaded this source code but it is showing some errors in Manager.java file,
        I am a fresher to android gaming apps.

        please send me the executable source code of this application, It will help me a lot.

  2. Sage says:

    Hi, Thanks for posting this game code. This was really helpful. I was trying to add some more functionality to this code like show all cards by clicking a button, so I was wondering if you could help me with that.

    I am very new to programming so your help will be highly appreciated.

    Thanks in advance!

  3. Anonymous says:

    thank you very much! it is really helpful in doing my game development home work

  4. shikoo says:

    thank you very much!

  5. sharu says:

    thank you very much! it is really helpful in doing my game development.

  6. Hasif says:

    Hi…I’m new to JAVA for Android…
    For my sch project, i decided to do a memory game.
    i have decided to use ur source code..however, there is no error but when i run it in sdk-android, the game force close..
    plz help !!!

  7. Jose says:

    hi i was looking at this code, pretty good , really really good, ive been peeking and poking it , and was wondering how would one make the pictures have certain space on the phone, what i mean is , having them cover all the screen of the phone in land and port mode, having them separated by certain amount of space

  8. rizky says:

    There was an error on ArrayAdapter statement and import java.util.regex.Pattern;

    Could you help me please? Thx! :)

    • admin says:

      Hi rizky,
      java.util.regex.Pattern is a standard import, there shouldn’t be a problem with it- try cleaning your project.

      Send me the error message of the ArrayAdapter .

      • rizky says:

        The error message: ArrayAdapter is a raw type. References to generic type ArrayAdapter should be parameterized

        What should i do?

  9. macarius2 says:

    Thank you !! it’s very usefull !!

    However i have one question about your “Manager.java” :
    In which part of the code, do you duplicate the different image ??

    thx again

    • admin says:

      I am not sure I understood the question but i’ll try to help.

      in loadCards() I create a list of sorted numbers according to the number of the cards.
      Than I pull them one by one in random order and order them in a matrix according to the cards on the table
      but first I divide the number by 2 so that each 2 cards on the table will hold the number.

      Now look at the function turnCard() – when a user click on a card I take the image
      according to the number it holds. This is how 2 cards on the table hold the same image.

      Does that answer your question?

      • macarius2 says:

        Yes it’s perfect !!!
        Thx you very much

        • macarius2 says:

          I have an other question, :)
          If i want to change this line : if(cards[seconedCard.x][seconedCard.y] == cards[firstCard.x][firstCard.y]){ …
          by on other which chek if, for example, an apple and a banana are found on the same turn, and then those cards become invisible … How should i do ?
          Maybe : if(cards[seconedCard.x][seconedCard.y] == R.drawable.card1 && cards[firstCard.x][firstCard.y] == R.drawable.card2) { …
          or something like that ??

          I hope that it’s rather understandable !

          Thx

  10. Jason M says:

    Great sample! I am modifying this to have some pics my son likes, but I noticed an issue with large resolution screens. In Droid phones it works great, but on my 2.2 pad if you empty a row of cards via matching, the layout shrinks and new cards you turn over are resized…basically, smashed. I can rework the code to use fixed sized containers for each card/cell, but I’d rather not if you already saw it and resolved it. Again, thanks for this code, it is a great way to start customizing my own similar game.

  11. dindin says:

    wow.. you are very good.. thank you.
    It really helped me in learning :)

  12. ranjeet says:

    Sir,
    The code have some error please tell me what can i do?

  13. lones says:

    There are some errors:
    1. The method onClick(View) of type Manager.ButtonListener must override a superclass method
    2. The method onItemSelected(AdapterView, View, int, long) of type new AdapterView.OnItemSelectedListener(){} must override a superclass method
    3. The method onNothingSelected(AdapterView) of type new AdapterView.OnItemSelectedListener(){} must override a superclass method

    • admin says:

      Hi lones,
      I have just downloaded the project and imported it into my eclipse.
      It compiles and run as it should.
      Here’s a suggestion, try cleaning your project in eclipse, see if that’s help.
      Also, make sure you havent got any environment related problems.
      Do you have problems with some of the imports?

  14. brusk says:

    Hi

    Thanks for your source code, but I have a problem when I next started eclipse..

    I have a problem with arrayAdapter, eclipse give me two option
    1. Create field “array” in R tipe
    2. Create constant “array” in R tipe

    What I have todo…?

    Thanks again..

    • admin says:

      Ignore the suggestions from eclipse, they are not good.

      Make sure you have added all the files from my project (including all the files under the ‘res’ folder).
      Try cleaning the project in eclipse.
      Is that helps?

  15. Anonymous says:

    thx alot

    very helpful

  16. Andal says:

    Hey. Thanks for the code! :) It works perfectly fine. But can you explain me why do you use “log” in your program? I don’t understand what it is used for. Also suggest me links where I can find material to read about it.

  17. Avi says:

    Log is a tool for developers to print messages and parameters values while the program is running.
    Let’s say for example you would like to see the value of parameter X in diffrent times of the program, than you can use the Log to print it’s value in diffrent times.
    The log is also used to print errors.
    All the messages are displayed in the log cat console.

    http://developer.android.com/guide/developing/debugging/debugging-log.html
    http://developer.android.com/reference/android/util/Log.html

  18. Maciek says:

    Don’t know why I can’t compile it back to the apk file. At first blush exerything seems to be ok but is not. File has been compiled but is not working on my HTC… Could you please help me?

  19. champ says:

    thaxx a lot…now i will be copying it for my collg project…mmuuaahhh

  20. Renato says:

    Thanks Man !!

  21. lilman says:

    hey
    i got the same problem with arrayAdapter.. how can i fix it? any suggestions?

  22. faisal says:

    Hi,
    You have done excellent job. Very nice. Though I tried to build it but it did not build.
    Could you please give the working source code

Leave a Reply