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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:37:25+00:00 2026-06-13T21:37:25+00:00

I’m having a problem with populating my spinner with days of the week. layout

  • 0

I’m having a problem with populating my spinner with days of the week.

layout xml:

<Spinner 
    android:id="@+id/week_spinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:drawSelectorOnTop="true"/>

strings.xml

<resources>
  <string-array name="days_of_week">
    <item>Monday</item>
    <item>Tuesday</item>
    <item>Wednesday</item>
    <item>Thursday</item>
    <item>Friday</item>
  </string-array>
</resources>

java:

public class AddModule extends Activity {
    Spinner day;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        day = (Spinner)findViewById(R.id.week_spinner);

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.days_of_week, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        day.setAdapter(adapter);
        setContentView(R.layout.activity_add_module);
    }
}

It’s the setAdapter line that’s causing the app to crash. I’m getting the following errors

11-05 21:24:31.235: W/dalvikvm(867): threadid=1: thread exiting with uncaught exception (group=0x40a9a228) 
11-05 21:24:31.245: E/AndroidRuntime(867): FATAL EXCEPTION: main 
11-05 21:24:31.245: E/AndroidRuntime(867): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cathal.timetable/com.cathal.timetable.AddModule}: java.lang.NullPointerException 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.access$600(ActivityThread.java:139) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.os.Handler.dispatchMessage(Handler.java:99) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.os.Looper.loop(Looper.java:154) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.main(ActivityThread.java:4974) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at java.lang.reflect.Method.invokeNative(Native Method) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at java.lang.reflect.Method.invoke(Method.java:511) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at dalvik.system.NativeStart.main(Native Method) 11-05 21:24:31.245: E/AndroidRuntime(867): Caused by: java.lang.NullPointerException 11-05 21:24:31.245: E/AndroidRuntime(867):    at com.cathal.timetable.AddModule.onCreate(AddModule.java:18) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.Activity.performCreate(Activity.java:4538) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071) 
11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158) 
11-05 21:24:31.245: E/AndroidRuntime(867):  ... 11 more

This was working fine yesterday. I can’t figure out if I maybe changed something or if I have an eclipse problem.

  • 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-13T21:37:27+00:00Added an answer on June 13, 2026 at 9:37 pm
    super.onCreate(savedInstanceState);
    setContentView(yourView);
    day = (Spinner)findViewById(R.id.week_spinner);
    

    You forgot to set view before getting spinner from xml. If you don’t set view, findViewById returns null.

    Any operation on null reference results in NullPointerException.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.