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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:14:46+00:00 2026-06-11T01:14:46+00:00

I just starting using ActionBarSherlock for building some simple app, in my first screen

  • 0

I just starting using ActionBarSherlock for building some simple app,
in my first screen I have simple list and I added new menu item for adding new item to the list:

MenuItem newItem = menu.add("New");
newItem.setIcon(R.drawable.ic_compose_inverse)
    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

now when user choose to add a new item I want to start a new action mode for adding new item, this action mode should contain a simple layout with text box and a button, so I created this layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

        <EditText
            android:id="@+id/text"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="text" >
        </EditText>
        <Button
            android:id="@+id/addBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/add" />
</LinearLayout>

so now I just need to set this layout to the bar in the new action mode:

newItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                actionMode = startActionMode(new MyAction(ListEditor.this));
                return true;
            }
        });

and in my action:

private final class MyAction implements ActionMode.Callback {
    ...
    @Override
    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        View customNav = LayoutInflater.from(context).inflate(R.layout.add_item, null);
        getSupportActionBar().setCustomView(customNav);
        getSupportActionBar().setDisplayShowCustomEnabled(true);
        return true;
    }
}

So basically I need something between ActionModes and CustomNavigation from the sherlock example, but the problem is that it set the layout to the main bar and not for the new bar that open in for action.

any suggestions?

  • 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-11T01:14:48+00:00Added an answer on June 11, 2026 at 1:14 am

    You probably want to use the method in the ActionMode class called “setCustomView” .

    so something like this:

    newItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                actionMode = startActionMode(new MyAction(ListEditor.this));
                actionMode.setCustomView(customNav);
                return true;
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just reinstalled LAMPP. When I try starting LAMPP using /opt/lampp/lampp start ,
Just starting using the Firebug console. I have a test script which I'll post
I'm just starting to learn F# using VS2010 and below is my first attempt
I'm just starting with jQuery, and having trouble doing something embarrassingly simple: using .load()
I'm just starting to learn Javascript; I do however have experience in programming using
I have searched, but nothing happens, I just starting using C#.NET and I a
I'm just starting to learn Java database persistence using Hibernate ORM and have run
Im just starting to work with NHibernate. I've setup a simple many-to-many scenario using
Just starting to learn scala for a new project. Have got to the point
We're just starting with SVN (were using CVS before :shame:) and I have 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.