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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:37:51+00:00 2026-06-12T22:37:51+00:00

I have the following code in my app. There is a login button which

  • 0

I have the following code in my app. There is a login button which works fine on my view. I’ve overridden the optionsmenu on my view and placed the login code inside a listener attached to the optionsmenu. When i press the optionsmenu login button nothing happens on the first click, but everything works fine on subsequent clicks. Why is this?

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // TODO Auto-generated method stub
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.layout.menuentryoptionsmenu, menu);
        return true;

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {


        case R.id.login:
                        item.setOnMenuItemClickListener(new OnMenuItemClickListener(){

                            @Override
                            public boolean onMenuItemClick(MenuItem item) {
                                // TODO Auto-generated method stub
                                Log.e(TAG, "login clicked from opts menu");
                                 compId = "100";
                                    String theUsername = userName.getText().toString();
                                    thePassword = passwordPin.getText().toString();
                                    String loginType = "1";



                                    String[] params = new String[]{compId, theUsername, thePassword, loginType};

                                    //validate user Asynchonously on background thread
                                    AsyncValidateCarer avc = new AsyncValidateCarer();
                                    avc.execute(params);
                                return true;
                            }});


            return true;


        case R.id.changeuser:
            if(isAllowChangeUser.equalsIgnoreCase("false")){
            item.setVisible(false);
            }
            return true;



        default:

            return super.onOptionsItemSelected(item);
        }
    }
  • 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-12T22:37:52+00:00Added an answer on June 12, 2026 at 10:37 pm

    Remove the click listener.
    Just put the whole login code after the case R.id.login:.

    That’s because onOptionsItemSelected is already the click, you don’t have to create and set it again.

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

Sidebar

Related Questions

I have the following code in my Backbone app, Is there a way to
I have following code which is not working on sencha touch 2, is there
Let's say I have the following code in Google App Engine: from urllib import
In my Zend Framework app, I have following code: index.php $app_started_time = time(); layout.phtml
I have the following code that allows my console app to go to the
I have the following code: <fx:Script> <![CDATA[ import shared.GlobalsManager; import app.Globals; protected var globals:Globals=GlobalsManager.getGlobals();
In my viewDidLoad method of my iPhone app I have the following code: zombie[i].animationImages
I'm doing a small app in Excel, and I have the following code when
Im trying to get debugging working without an app.config. I have the following code:
So, I'm finishing up an iPhone App. I have the following code in place

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.