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 7599907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:46:34+00:00 2026-05-30T22:46:34+00:00

I currently have Button in my main view which checks if users answer is

  • 0

I currently have Button in my main view which checks if users answer is correct.

Button CheckButton= (Button) this.findViewById(R.id.CheckButton);

    CheckButton.setOnClickListener(new OnClickListener() 
    {
    public void onClick(View v) {
                // some action, setting text
        }
            }); 

If button is pressed once it checks if answer is correct, and if button is pressed second time I want it to repeat activity e.g. present user with another question.

OnClickListener is inside onCreate method and question is generated using switch and unique id (for game difficulty).

What would be the best way to set this repeat activity until it’s been repeated 4 times. Thanks

switch (difficulty_level) 
{

case DIFFICULTY_HARD:

// do this

case DIFFICULTY_EASY:

// do 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-05-30T22:46:36+00:00Added an answer on May 30, 2026 at 10:46 pm

    To me, this doesn’t sound like logic belonging in the OnClickListener at all. The listener should simply register the click and then call a function in your activity “handleButtonClicked” that have access to fields that keep track of the number of clicks for the question, if the answer is correct and what the appropiate action is.

    The fact that the OnClickListener is set in the onCreate only says that it is ready to be used after OnCreate. It doesn’t require the OnCreate to be run again.

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

Sidebar

Related Questions

This is my problem, I have the main view which only shows one button,
I have a footer view in the list view which contain a button Search
I want to launch a new fragment to view some data. Currently, I have
I currently have a simple form that when you click the save button will
I currently have my code set to disable the submit button when the field
Currently, I have some basic code to play a simple tone whenever a button
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I currently have this workflow in a tab based app: Tab1 loads... ViewOne :
Im new to this android development, and im currently playing around with the HelloM4A
I have a UserControl which I want to have 3 possible states: -Main menu

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.