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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:23:02+00:00 2026-06-14T03:23:02+00:00

When I try to configure SearchView like in documentation I get this error if

  • 0

When I try to configure SearchView like in documentation I get this error if using ActionBarSherlock:

FATAL EXCEPTION: main
java.lang.ClassCastException: android.widget.SearchView cannot be cast to com.actionbarsherlock.widget.SearchView
    at MY_PACKAGE.ACTIVITY.onCreateOptionsMenu(MenuDrawerBase.java:181)
    at android.support.v4.app.Watson.onCreatePanelMenu(Watson.java:45)
    at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559)
    at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60)
    at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:165)
    at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
    at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
    at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2913)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)

My code is exactly as in example:

import com.actionbarsherlock.view.*;
import com.actionbarsherlock.widget.SearchView;
......
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getSupportMenuInflater().inflate(R.menu.main, menu);
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView)menu.findItem(R.id.action_search).getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(true);
        searchView.setSubmitButtonEnabled(true);
        return true;
    }

Didn’t find description of this nowhere so asking you: what’s this?
By the way, if I use import android.widget.SearchView; instead of import com.actionbarsherlock.widget.SearchView; the application compiles and works with API greater than 11 but I need it on version 10.

  • 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-14T03:23:03+00:00Added an answer on June 14, 2026 at 3:23 am

    My apologies guys, but this was my mistake.
    Be aware of what class are you referencing in menu xml resource. In my case it was:

    <item android:id="@+id/action_search"
        android:title="@string/action_search"
        android:icon="@drawable/action_search_light"
        android:showAsAction="always|collapseActionView"
        android:actionViewClass="android.widget.SearchView"/>
    

    and this caused cast error. Changed actionViewClass to com.actionbarsherlock.widget.SearchView and got exactly what was expecting!

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

Sidebar

Related Questions

When I try to compile Gforth 0.7.0, I get the following error: $ ./configure
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
I'm getting the following error when I try to install mod_wsgi ./configure checking for
Try this piece of code - public class WhitespaceTest { public static void main(String[]
Using: InterBase 2007, latest interclient.jar (8.1.8), GlassFish v3 b68. I try to configure the
I'm trying to configure a new site. I try to surf and get the
I am trying to configure Git repository using Xcode 4. When I try to
Download latest version of ImageMagick. Unpacked it. Installing Ghostscript like this: $ sudo apt-get
I followed this a link to try to configure Twitter's boostrap.less under Node 0.6.12
I try to configure varnish so it can handle jsonp. I use as the

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.