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

  • Home
  • SEARCH
  • 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 7830801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:24:44+00:00 2026-06-02T11:24:44+00:00

I want to do something, where I will have 4 buttons. There will only

  • 0

I want to do something, where I will have 4 buttons. There will only be a success if 2 matching buttons are pressed. At the moment I only know how to handle one button click, but I don’t know how to make it so that if I press a button, and then afterwards press another button.. a fail or success occurs depending on the button pressed.

What would I use to go on about implementing this?

  • 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-06-02T11:24:45+00:00Added an answer on June 2, 2026 at 11:24 am

    If you mean that you want to detect simultaneous press of two buttons, you can set an OnTouchListener for the buttons and detect when each one is pressed or released. With a little bookkeeping, you can then detect whether the user presses two matching buttons at the same time.

    If you want to track successive button clicks, then you need some way of identifying which button was last clicked. There are a couple of ways to do this. One is to assign a different OnClickHandler (or a different android:onClick method) to each button. Another way (better, in my opinion) is to assign a unique tag value to each button. In XML, the tag will be a string, which you can then parse into an int value using Integer.parseInt(); in code it can be an Integer. Then your click handler determines the button’s tag value and uses that in the program logic.

    The way you would use this is as follows. Define a field in your game class for the last button clicked. Before any buttons are clicked, it should have the value -1 (indicating no button). Then when you get a button click, determine its identity (either from the tag or by which click handler was invoked). Check whether the last button and the current button form a correct sequence. If not, then set the last button to the current button.

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

Sidebar

Related Questions

I want something to put in my .htaccess file that will hide the .php
I'm writing a simple news site. I want that the URL will be something
I have an keyup handler. I want something to happen every time I press
I want it so when the x button is clicked a message box will
I have 30 buttons with nothing in default text value. What i want to
I have 5 buttons named opt1, opt2, opt3, etc. If I want to hide/show/do
I just learned that an object can have only one ID, so I'm not
I have a text box in my page which the user will type something
I want something like a canvas, but where i'd be able to manipulate pixels
I want something like this: abcdab.search(/a/g) //return [0,4] Is it possible?

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.