Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3361426
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:09:04+00:00 2026-05-18T03:09:04+00:00

) I’m in a process of creating a memory game. My problem is that

  • 0

)
I’m in a process of creating a memory game. My problem is that whenever i click for the second time, i can’t even see toggled button. To be clear – first click toggles the togglebutton, so i can see the number it holds, the second click on a different togglebutton is suposed to toggle it, show me the number and then proceed to either set a score +1 if numbers are the same, or reverse them back again if they’re different.

Below is the code that i use as my onClick function, i’ve been thinking about putting some kind of sleep or delay function somwhere in the second “if block” – (if(klikniecia ==2)).

Any help on this topic would be appreciated.

public void onClick(View view) {
for (int i = 0; i < karta.length; i++){
    if (view == karta[i]){
        karta[i].setEnabled(false);
        klikniecia++;
        if (klikniecia == 1){
            kartaID[0]=i;
            kartaWartosc[0]=listaKart.get(i);

        }
        if (klikniecia == 2){
            kartaID[1]=i;
            kartaWartosc[1]=listaKart.get(i);

            //i think, about setting a delay here, so i can see both of the cards, regardles if the're the same or not before reverting them.

            if (czyPara()){
                karta[kartaID[0]].setEnabled(false);
                karta[kartaID[1]].setEnabled(false);
                klikniecia=0;
            }
            else{

                karta[kartaID[0]].setEnabled(true);
                karta[kartaID[0]].toggle();
                karta[kartaID[1]].setEnabled(true);
                karta[kartaID[1]].toggle();
                klikniecia=0;

            }
        }

    }

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:09:05+00:00Added an answer on May 18, 2026 at 3:09 am

    Instead of sleeping in the onclick, you could post a delayed message to a handler (with associated runnable) and have it update the UI. Obviously fit this into the design of your app and make it work, but the basic idea is this:

    //Here's a runnable/handler combo
    private Runnable mMyRunnable = new Runnable()
    {
        @Override
        public void run()
        {
           //Change state here
        }
     };
    

    Then from onClick you post a delayed message to a handler, specifying that runnable to be executed.

    Handler myHandler = new Handler();
    myHandler.postDelayed(mMyRunnable, 1000);//Message will be delivered in 1 second.
    

    Depending on how complicated your game is, this might not be exactly what you want, but it should give you a start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.