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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:40:52+00:00 2026-06-10T11:40:52+00:00

I have 2 buttons in my code, ‘Clear’ and ‘Login’, the problem is the

  • 0

I have 2 buttons in my code, ‘Clear’ and ‘Login’, the problem is the login button can’t be clicked, but the clear button works just fine.
Where is my mistake?

The code below is the entire project

public MyScreen()
{        
    // Set the displayed title of the screen       
    Bitmap logo = Bitmap.getBitmapResource("icon.png");
    bitField = new BitmapField(logo, Field.FIELD_HCENTER);
    userField = new EditField("Username :", "");
    passField = new PasswordEditField("Password :", "");
    ddlDomain = new ObjectChoiceField("Domain :", new String[] {"Home", "Work"});
    chkRemember = new CheckboxField("Remember Password", false);
    btnClear = new ButtonField("Clear", ButtonField.CONSUME_CLICK);
    btnLogIn = new ButtonField("Log In", ButtonField.CONSUME_CLICK);
    add(bitField);
    add(new SeparatorField());
    add(new LabelField("Please enter your credentials:"));
    add(userField);
    add(passField);
    add(ddlDomain);
    add(chkRemember);
    HorizontalFieldManager btnManager = new HorizontalFieldManager(Field.FIELD_RIGHT);
    btnManager.add(btnClear);
    btnManager.add(btnLogIn);
    add(btnManager);

    btnClear.setChangeListener(this);
}

public void fieldChanged(Field field, int context) {
    if(field == btnClear){
        clearTextFields();
    }
    else if(field == btnLogIn){
        login();
    }
}
private void clearTextFields(){
    userField.setText("");
    passField.setText("");
}
private void login(){
    if(userField.getTextLength() == 0 || passField.getTextLength() == 0){
        Dialog.alert("You must enter a username and password");
    }
    else{
        String username = userField.getText();
        String selectedDomain = (String)ddlDomain.getChoice(ddlDomain.getSelectedIndex());
        SuccessScreen loginSuccess = new SuccessScreen(username, selectedDomain);
        UiApplication.getUiApplication().pushScreen(loginSuccess);
    }
}
  • 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-10T11:40:54+00:00Added an answer on June 10, 2026 at 11:40 am

    Hi dear you need to add

    btnLogIn.setChangeListener(this);
    

    try this

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

Sidebar

Related Questions

I have following code which works for radio buttons but need to be changed
I have something like the code below: for(int i=0;i<10;i++){ button=new JButton(buttons[i]); button.addActionListener(new ActionListener(){ public
I have code that works great for adding a button to the toolbar: NSArray*
I have 12 buttons in ASP.NET page. I want to color the button; But
I have buttons and a selector for the buttons, the code looks like this:
I have a code in jquery mobile that will add buttons dynamically in a
I have the following code which creates a simple window with two buttons which
I have created an alert view with two buttons using the following code: UIAlertView
I have WPF Form which has many buttons with the same code. Appearance of
I have this code and I want to have my button as a square,

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.