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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:59:55+00:00 2026-06-10T06:59:55+00:00

I am using ActionBarSherlock, in the ActionBar i have this custom layout to appear

  • 0

I am using ActionBarSherlock, in the ActionBar i have this custom layout to appear when i click on the searchIcon.

public boolean onCreateOptionsMenu(final Menu menu) {
LayoutInflater inflater = getLayoutInflater();
final View view = inflater.inflate(R.layout.on_search_icon_clicked,null, false);
view.findViewById(R.id.search_image).setOnClickListener(
        new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {

        EditText searchET = (EditText) view.findViewById(R.id.search_editText);
        String s = searchET.getText().toString();
        Toast.makeText(getBaseContext(), "Searching for: " + s,1000).show();
                    }
        });

menu.add("Search")
        .setIcon(R.drawable.ic_search)
        .setActionView(view)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
        return true;
}

on_search_icon_clicked.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/search_image"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_search"
        android:clickable="true"
        android:contentDescription="@string/seach_icon" />

    <EditText
        android:id="@+id/search_editText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/search_image"
        android:hint="@string/search"
        android:singleLine="true" />

</RelativeLayout>

So, i click on the SearchIcon —> i get the custom layout with editText and ImageView —> click on editText, opens softkeyboard —> enters string and clicks the imageView —> shows me the toast.

Its fine till here.

The problem is:

i close the softkeyboard using device back button —> then close the custom layout using ActionBar Home icon click —> now click the searchIcon again, which reopens the custom layout, with editText filled with previously searched string —> click on the editText, the softkeyboard doesn't open up (here is the problem).

Please help, i have no idea why its not working as expected.

Thank You

  • 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-10T06:59:57+00:00Added an answer on June 10, 2026 at 6:59 am

    I have faced this problem before and here is my solution

    //your_menu
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <item
        android:id="@+id/menu_search"
        android:orderInCategory="0"
        android:icon="@drawable/btn_search"
        android:title="Search"
        android:actionLayout="@layout/on_search_icon_clicked"
        android:showAsAction="always|collapseActionView"
       />
    </menu>
    
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {       
        getSupportMenuInflater().inflate(R.menu.your_menu, menu);
        mSearchbar = (MenuItem) menu.findItem(R.id.menu_search);
        View actionview = mSearchbar.getActionView();
        mEtSearchbar = ((EditText) actionview.findViewById(R.id.search_editText));
        mEtSearchbar.setOnEditorActionListener(this);       
        mEtSearchbar.addTextChangedListener(this);      
        super.onCreateOptionsMenu(menu);
        return true;
    }
    
    
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        Intent intent;
        switch (item.getItemId())
        {
            case R.id.menu_search:                  
                mEtSearchbar.clearFocus();
                 (new Handler()).postDelayed(new Runnable() {
                    public void run() {
                        mEtSearchbar.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0));
                        mEtSearchbar.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0));
                    }
                 }, 100);
                break;          
            default:
                break;
        }
    
        return super.onOptionsItemSelected(item);
    }
    

    mEtSearchbar ~ your searchET

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

Sidebar

Related Questions

I have an activity using ActionBarSherlock with ActionBar.NAVIGATION_MODE_LIST . When entering the page I
I am using ActionBarSherlock and have an ActionBar with navigation tabs in it. I
I am using ActionBarSherlock and have implemented ShareActionProvider . When a user selects an
I'm using ActionBarSherlock and have a little problem. In the Fragment Tabs example, there
Using ActionBar Sherlock to implements tabs, I have a new TabsAdapter object declared and
I am trying to hide the title part of my actionbar using ActionBarSherlock like
I'm using ActionBarSherlock to implement an ActionBar with tabs in my application. When I
currently i am using ActionBarSherlock for my project. I am creating my actionbar with
When using the Android Actionbar I am doing the following in the onCreateOptionsMenu override:
I am using IntelliJ Idea CE (which is incredible) and have included ActionBar Sherlock

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.