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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:06:28+00:00 2026-06-09T19:06:28+00:00

Currently I have two activitys inside one tab. In second activity I have custom

  • 0

Currently I have two activitys inside one tab. In second activity I have custom list and custom spinner. The data for the spinner and listview is received from server…. That works OK. so when I click on the spinner in my second activity the app crashes and the logcat says:

08-13 11:54:55.908: E/AndroidRuntime(13555): java.lang.NullPointerException
08-13 11:54:55.908: E/AndroidRuntime(13555):    at  android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.ArrayAdapter.getDropDownView(ArrayAdapter.java:376)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:332)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.Spinner$DropDownAdapter.getView(Spinner.java:328)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.AbsListView.obtainView(AbsListView.java:1474)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.ListView.onMeasure(ListView.java:1127)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.View.measure(View.java:8335)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.View.measure(View.java:8335)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.View.measure(View.java:8335)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.View.measure(View.java:8335)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.View.measure(View.java:8335)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.ViewRoot.performTraversals(ViewRoot.java:843)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1892)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.os.Looper.loop(Looper.java:130)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at android.app.ActivityThread.main(ActivityThread.java:3835)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at java.lang.reflect.Method.invokeNative(Native Method)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at java.lang.reflect.Method.invoke(Method.java:507)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
08-13 11:54:55.908: E/AndroidRuntime(13555):    at dalvik.system.NativeStart.main(Native Method)

I have been looking at these posts -> Android :WindowManager$BadTockenException on Spinner Click that solved my first issue and Problem with spinner in custom list inside activity group that gave me nothing.

So here’s how I set views and spinner and my custom adapter:

  View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.atlaides, null);
    this.setContentView(viewToLoad); 
    //setContentView(R.layout.atlaides);
    sp = (Spinner)  viewToLoad.findViewById(R.id.spinner1);

  MySpiner sxspin =  new MySpiner(this.getParent(), R.layout.c_spinner, android.R.id.text1, categories);
    sxspin.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);

    this.sp.setAdapter(sxspin);

and my custom spinner adapter looks like this:

private class MySpiner extends ArrayAdapter<String>{

    public MySpiner(Context context, int resource, int textViewResourceId,
            List<String> objects) {
        super(context, resource, textViewResourceId, objects);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        LayoutInflater pieputejs = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = pieputejs.inflate(R.layout.c_spinner, parent,false);
        TextView text = (TextView)view.findViewById(R.id.textView1);
        text.setText(categories.get(position));
        //text.setTextColor(Color.GRAY);
        //text.setShadowLayer(2.5f, 2, 2, Color.WHITE);
        //text.setGravity(TextView.FOCUS_LEFT);

        return view;
    }       
}
  • 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-09T19:06:29+00:00Added an answer on June 9, 2026 at 7:06 pm

    That NullPointerException doesn’t come from the custom adapter MySpinner it comes from another simple ArrayAdapter that you have somewhere else in your code. In the data that you supply to that ArrayAdapter you have null values and that is what most likely throws the NullPointerException. See what data you pass and remove the null values from it.

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

Sidebar

Related Questions

I currently have two SQL commands. One retrieves a list of unique IDs from
I (currently) have two forms, one that needs to call the other. In other
I currently have a simple list view adapter that holds two rows of text.
I have one problem using ActivityGroup. I have two activities inside an ActivityGroup and
I currently have a UIActivityIndicator appearing on screen for a second or two. I
I have two relative layouts that are currently displayed one below the other. I
I have a custom listview which changes size when one of the rows is
lets say, i have two tables, one for object records and one for activity
I have two Activities in my App, one is a ListView which displays a
I have two activities A and B. I am currently in Activity A and

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.