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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:35:10+00:00 2026-06-15T18:35:10+00:00

I currently have four buttons. The fourth button is a reset button I added

  • 0

I currently have four buttons. The fourth button is a reset button I added to reset the activity to the state when it was originally started. However, when I added the reset button it disabled one of the buttons permanently, even though previously, the buttons were being enabled/disabled the way they were supposed to. Here is the relevant code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_name);

    // non relevant code

    okButton = (Button) findViewById(R.id.ok);
    okButton.setOnClickListener(this);

    changeButton = (Button) findViewById(R.id.change_button);
    changeButton.setOnClickListener(this);

    nextButton = (Button) findViewById(R.id.next_button);
    nextButton.setEnabled(false);
    nextButton.setOnClickListener(this);

    reset = (Button) findViewById(R.id.reset);
    reset.setEnabled(false);
    reset.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.ok:
        changeButton.setEnabled(false);
        okButton.setEnabled(false);
        nextButton.setEnabled(true);
        break;

    case R.id.change_button:
        changeButton.setEnabled(false);
        okButton.setEnabled(false);
        nextButton.setEnabled(true);
        break;

    case R.id.next_button:
        nextButton.setEnabled(false);
        okButton.setEnabled(true);
        changeButton.setEnabled(true);
        break;

    case R.id.reset:
        Intent intent = getIntent();
        finish();
        startActivity(intent);
        break;

    default:
        break;
    }
}

Everything was working as it should have until all of the parts involving the reset button were added. Essentially, the behaviour I want is:

  • Initially: next and reset are disabled, they become enabled when either change or ok are clicked

  • When either change or ok are clicked, they both are disabled (to prevent clicking more than once) and both reset and next are enabled

  • When next or reset are clicked, they become disabled and change and ok become enabled.

The change, ok, and next button behaviors were working until the reset code was added. Then the next button became permanently disabled. What is wrong? How do I fix it?

EDIT*:

Here is the xml code for the buttons:

<Button
    android:id="@+id/ok"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/change_button"
    android:layout_alignBottom="@+id/change_button"
    android:layout_toLeftOf="@+id/reset"
    android:text="@string/Ok" />

<Button
    android:id="@+id/next_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/change_button"
    android:layout_alignBottom="@+id/change_button"
    android:layout_alignParentLeft="true"
    android:text="@string/next_button" />

<Button
    android:id="@+id/reset"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="@string/reset" />

<Button
    android:id="@+id/change_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="14dp"
    android:layout_toRightOf="@+id/next_button"
    android:text="@string/change" />
  • 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-15T18:35:11+00:00Added an answer on June 15, 2026 at 6:35 pm

    Initially: next and reset are disabled, they become enabled when
    either change or ok are clicked

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.ok:
            changeButton.setEnabled(false);
            okButton.setEnabled(false);
            nextButton.setEnabled(true);
            reset.setEnabled(true); // add this
            break;
    
        case R.id.change_button:
            changeButton.setEnabled(false);
            okButton.setEnabled(false);
            nextButton.setEnabled(true);
            reset.setEnabled(true); // add this
            break;
    
        case R.id.next_button:
            nextButton.setEnabled(false);
            okButton.setEnabled(true);
            changeButton.setEnabled(true);
           reset.setEnabled(false); // add this
            break;
    
        case R.id.reset:
            Intent intent = getIntent();
            finish();
            startActivity(intent);
            break;
    
        default:
            break;
        }
    }
    

    This worked for me/ Add those lines.

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

Sidebar

Related Questions

We currently have one publisher and four subscribers using merge replication. Due to a
I currently have a view with four buttons, and would like to be able
I have four classes which share some arrangement of four properties. I have currently
I currently have a GridPanel with the Ext.ux.RowEditor plugin. Four fields exist in the
Currently I have Long Pres Gesture Recognizers on four different TableViews (two in each
Currently have password protection on my main and sub directories, however I'd like to
I currently have one project that currently contains multiple packages. These packages make up
How do you create a Browse button in a WIX dialog. I currently have
So I have four buttons, all of them use match_parent for both height and
I currently have a page with four list boxes on it and imagine a

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.