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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:58:52+00:00 2026-06-09T17:58:52+00:00

I have an android app, written in java that contains, amongst other things, a

  • 0

I have an android app, written in java that contains, amongst other things, a spinner, shown in the layout.xml as follows:

<Spinner
    android:id="@+id/sprDeviceType"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

It is initialised in the activity class as follows:

public class AddDevice extends Activity
{
    private Spinner deviceTypeSpinner;

    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.add);  //Set the layout

        populateDeviceTypeSpinner();
    }

    private void populateDeviceTypeSpinner()
    {
        String device_type_spinner[];

        device_type_spinner = new String[2];
        device_type_spinner[0] = "FTP";
        device_type_spinner[1] = "QAF";

        deviceTypeSpinner = (Spinner) findViewById(R.id.sprDeviceType);

        ArrayAdapter deviceTypeArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, device_type_spinner);

        deviceTypeSpinner.setAdapter(deviceTypeArrayAdapter);
    }
}

However, when I run the program, it opens the activity fine, but when I click the spinner to get the drop down items, it crashes the program, throwing a NullPointerException.

Anyone see what I’m doing wrong?

The LogCat shows:

08-14 14:57:02.034: D/AndroidRuntime(1612): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
08-14 14:57:02.034: D/AndroidRuntime(1612): CheckJNI is OFF
08-14 14:57:02.074: D/AndroidRuntime(1612): --- registering native functions ---
08-14 14:57:05.004: D/AndroidRuntime(1612): Shutting down VM
08-14 14:57:05.014: I/AndroidRuntime(1612): NOTE: attach of thread 'Binder Thread #3' failed
08-14 14:57:05.184: D/AndroidRuntime(1637): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<
08-14 14:57:05.184: D/AndroidRuntime(1637): CheckJNI is OFF
08-14 14:57:05.224: D/AndroidRuntime(1637): --- registering native functions ---
08-14 14:57:05.524: D/AndroidRuntime(1637): Shutting down VM
08-14 14:57:05.544: I/AndroidRuntime(1637): NOTE: attach of thread 'Binder Thread #3' failed
  • 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-09T17:58:54+00:00Added an answer on June 9, 2026 at 5:58 pm

    I changed from using an array I programmed in, to using an array saved in a values xml.

    private void populateDeviceTypeSpinner()
    {
        deviceTypeSpinner = (Spinner) findViewById(R.id.sprDeviceType);
    
        ArrayAdapter<CharSequence> deviceTypeArrayAdapter = ArrayAdapter.createFromResource(this, R.array.deviceType, android.R.layout.simple_spinner_item);
    
        deviceTypeArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    
        deviceTypeSpinner.setAdapter(deviceTypeArrayAdapter);
    }
    
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string-array name="deviceType">
            <item >FTP</item>
            <item >QAF</item>
        </string-array>
    </resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have android application that is written regular way. layouts, java, APK. Now, depending
I have code written for Android 2.2 that is supposed to parse xml from
I have written a small android app that grabs some data and displays it
I have an android app written in java. The app basically connects to a
I have an android app written in java. The app basically connects to a
I have Android client app that communicates with server using Socket . On my
I have an Android app, that is using the SIM Toolkit. The application has
I have an android app that I am trying to launch and it gives
I have an Android app that has an Application class and I have another
I have written an Android application that uses SQLite database which is saved in

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.