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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:12:00+00:00 2026-05-23T12:12:00+00:00

(Android 3.0+) How would I create a Spinner for use as an Action Item

  • 0

(Android 3.0+) How would I create a Spinner for use as an Action Item for Android Honeycomb’s Action Bar? I understand that the Action Bar’s LIST mode pretty much does that, but I would like to use its TAB mode instead. Since, as far as I know, I can’t have both on at the same time, I’m trying to use the spinner as an action item instead.

Here is the java:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.spin_menu, menu);
    Spinner spin = (Spinner) findViewById(R.id.spin_widget);
    ArrayAdapter<CharSequence> spinAdaptor = ArrayAdapter.createFromResource(
         this, R.array.spinlist, android.R.layout.simple_spinner_item);
    spinAdaptor.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spin.setAdapter(spinAdaptor);
    return super.onCreateOptionsMenu(menu);
}

No errors appear in eclipse, but running the program results in a force close. Any suggestions for a absolute beginner?

Update – Added logcat error severity log: (At least, that’s what I think it is)

06-27 18:36:59.496: ERROR/AndroidRuntime(493): FATAL EXCEPTION: main
06-27 18:36:59.496: ERROR/AndroidRuntime(493): java.lang.NullPointerException
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at me.ics.icsActivity.onCreateOptionsMenu(icsActivity.java:84)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at android.app.Activity.onCreatePanelMenu(Activity.java:2389)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:347)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:647)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at com.android.internal.policy.impl.PhoneWindow$2.run(PhoneWindow.java:2581)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at android.os.Handler.handleCallback(Handler.java:587)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at android.os.Handler.dispatchMessage(Handler.java:92)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at android.os.Looper.loop(Looper.java:132)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at android.app.ActivityThread.main(ActivityThread.java:4025)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at java.lang.reflect.Method.invoke(Method.java:491)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-27 18:36:59.496: ERROR/AndroidRuntime(493): at dalvik.system.NativeStart.main(Native Method)

  • 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-05-23T12:12:01+00:00Added an answer on May 23, 2026 at 12:12 pm

    My guess is that you do not have a Spinner whose android:id is R.id.spin_widget.

    If you are trying to put a Spinner as an action item, as your question states, you would not get that Spinner via findViewById(), but rather by getActionView() on the MenuItem in question. Here is a sample project demonstrating this, implemented in a way that will work on Honeycomb but also successfully skips this code on older versions of Android.

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

Sidebar

Related Questions

For Android GUI: I would like to create a window that I can pull
I have an Android Spinner view in my layout. I would like that spinner
I would like to create autocompletetextview with loading spinner inside (like in bilt-in Android
I would like to create a seekbar for a Mono for Android app that
I would like to create a custom control in my Android App. It will
I'm trying to build an android app that would do a local search on
i would like to buy a new cell phone that runs Android. From what
I want to use a Spinner that initially (when the user has not made
I would like to create a custom Android button from 9patches, but without using
I would like to create a Java desktop application and an Android application so

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.