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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:43:42+00:00 2026-06-17T16:43:42+00:00

I use SherlockListActivity, I created ActionBar with one item & its clickListener when i

  • 0

I use SherlockListActivity,
I created ActionBar with one item & its clickListener
when i click on it for first time after creating activity, doesn’t call onMenuItemClick, but in every click after first click, work with no problem

Why ?

private void BuildTopActionBar() {
        BitmapDrawable bg = (BitmapDrawable) getResources().getDrawable(
                R.drawable.ic_action_bg);
        bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
        getSupportActionBar().setBackgroundDrawable(bg);

        this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        this.getSupportActionBar().setHomeButtonEnabled(true);
        this.getSupportActionBar().setTitle("bookmarks");
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            // This is called when the Home (Up) button is pressed in the Action Bar.
            finish();
            return true;
        case add_bookmark_item:
            // add
            item.setOnMenuItemClickListener(new OnMenuItemClickListener() {

                public boolean onMenuItemClick(MenuItem item) {
                    customAmbilWarnaDialog dialog = new customAmbilWarnaDialog(
                            BookMarksActivity.this, 0xffffffff,
                            new OnAmbilWarnaListener() {

                                public void onCancel(
                                        customAmbilWarnaDialog dialog) {
                                }

                                public void onOk(customAmbilWarnaDialog dialog,
                                        int color, String name, int hasName) {
                                    myDbHelper.AddNewBookmark(name,
                                            currentPageNum, color, hasName);
                                    // code
                                    lv.smoothScrollToPosition((lv.getCount() - 1));
                                }
                            });
                    dialog.show();                  
                    return true;
                }
            });

        }

        return super.onOptionsItemSelected(item);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        menu.add(0, add_bookmark_item, 0, "add bookmark")
                .setIcon(R.drawable.bookmark_add)
                .setShowAsAction(
                        MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
                                | MenuItem.SHOW_AS_ACTION_ALWAYS);

        return true;
    }
  • 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-17T16:43:43+00:00Added an answer on June 17, 2026 at 4:43 pm

    the reason is that you’re calling the item.setOnMenuItemClickListener(new OnMenuItemClickListener() {... in the onOptionsItemSelected() method.

    This means it will be set the first time you click the menuItem (and then reset on every click) and the code inside it will only run once you’ve clicked it at least once.

    either call this in onCreateOptionsMenu() or simply move the code from onMenuItemClick() to the switch/case

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

Sidebar

Related Questions

use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More no_plan; use Test::Exception;
Use of Unassigned local variable 'model'. Is what error message I'm getting. Its right
Use case: User clicks a link, a modal window is displayed containing one big
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Ok, so I'm trying to use Sherlock to display multiple tabs, each for one
Use case : one Java process with one or two C++ processes, always on
Use Case Show a photo uploaded by the user in a square box with
use C#,want to upload excel file on google doc. bellow syntax use to upload
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use the [] symbol in the name of the form field you are submitting

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.