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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:19:45+00:00 2026-06-02T05:19:45+00:00

I have a error when I get an array which has more than one

  • 0

I have a error when I get an array which has more than one value in it the ListView… it crashes…

str_amparticipant_firstname is an array of string values.
str_pmparticipant_firstname is also an array of string values.

 adapteram = new ArrayAdapter<String>(Attend.this, android.R.layout.simple_list_item_1, str_amparticipant_firstname);   

 adapterpm = new ArrayAdapter<String>(Attend.this, android.R.layout.simple_list_item_1, str_pmparticipant_firstname);   

          amattendees.setAdapter(adapteram);
          pmattendees.setAdapter(adapterpm);

The class is called Attend. the ListViews show the values in the array when there is one value in the array. If there is more than one value the app crashes. I have checked that the array is being filled correctly and it is. Hopefully the error log has the answer. The error log I am getting is below:

04-16 19:28:57.664: E/AndroidRuntime(5807): FATAL EXCEPTION: main
04-16 19:28:57.664: E/AndroidRuntime(5807): java.lang.NullPointerException
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.AbsListView.obtainView(AbsListView.java:1430)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1307)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.ListView.onMeasure(ListView.java:1127)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.View.measure(View.java:8510)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3202)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:701)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.View.measure(View.java:8510)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3202)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.View.measure(View.java:8510)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3202)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.View.measure(View.java:8510)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.View.measure(View.java:8510)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3202)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.View.measure(View.java:8510)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.ViewRoot.performTraversals(ViewRoot.java:871)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1921)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.os.Looper.loop(Looper.java:143)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at android.app.ActivityThread.main(ActivityThread.java:4196)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at java.lang.reflect.Method.invokeNative(Native Method)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at java.lang.reflect.Method.invoke(Method.java:507)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-16 19:28:57.664: E/AndroidRuntime(5807):     at dalvik.system.NativeStart.main(Native Method)

again the error only appears when there is more than one value in the array. I have tried to find an answer to this problem but I couldnt find any info on the error. please help! thankyou!

UPDATE: this is how the array is filled and created:

for(int i = 0; i < json_array_amparticipants.length(); i++){
                             //store all the amparticipants
                         str_amparticipant_email = new String[json_array_amparticipants.length()];
                         str_amparticipant_firstname = new String[json_array_amparticipants.length()];
                         str_amparticipant_lastname = new String[json_array_amparticipants.length()];         
                         str_amparticipant_attendingam = new String[json_array_amparticipants.length()];    
                         str_amparticipant_attendingpm = new String[json_array_amparticipants.length()];
                         //full_name_am = new String[json_array_amparticipants.length()];
                         str_amparticipant_email[i] = json_array_amparticipants.getJSONObject(i).getString("email");
                         str_amparticipant_firstname[i] = json_array_amparticipants.getJSONObject(i).getString("first_name");
                         str_amparticipant_lastname[i] = json_array_amparticipants.getJSONObject(i).getString("last_name"); 
                         str_amparticipant_attendingam[i] = json_array_amparticipants.getJSONObject(i).getString("attending_am");   
                         str_amparticipant_attendingpm[i] = json_array_amparticipants.getJSONObject(i).getString("attending_pm");
                         //full_name_am[i] = str_amparticipant_firstname[i] + str_amparticipant_lastname[i];

                     }

FIXED: I am creating new arrays every time so it still stores the value but it causes the crash… heres the updated fix. Cheers guys:

   //store all the amparticipants
             str_amparticipant_email = new String[json_array_amparticipants.length()];
             str_amparticipant_firstname = new String[json_array_amparticipants.length()];
             str_amparticipant_lastname = new String[json_array_amparticipants.length()];         
             str_amparticipant_attendingam = new String[json_array_amparticipants.length()];    
             str_amparticipant_attendingpm = new String[json_array_amparticipants.length()];


                 for(int i = 0; i < json_array_amparticipants.length(); i++){
                     //full_name_am = new String[json_array_amparticipants.length()];
                     str_amparticipant_email[i] = json_array_amparticipants.getJSONObject(i).getString("email");
                     str_amparticipant_firstname[i] = json_array_amparticipants.getJSONObject(i).getString("first_name");
                     str_amparticipant_lastname[i] = json_array_amparticipants.getJSONObject(i).getString("last_name"); 
                     str_amparticipant_attendingam[i] = json_array_amparticipants.getJSONObject(i).getString("attending_am");   
                     str_amparticipant_attendingpm[i] = json_array_amparticipants.getJSONObject(i).getString("attending_pm");
                     //full_name_am[i] = str_amparticipant_firstname[i] + str_amparticipant_lastname[i];

                 }
  • 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-02T05:19:49+00:00Added an answer on June 2, 2026 at 5:19 am

    This should be outside of your loop:

                             str_amparticipant_email = new String[json_array_amparticipants.length()];
                             str_amparticipant_firstname = new String[json_array_amparticipants.length()];
                             str_amparticipant_lastname = new String[json_array_amparticipants.length()];         
                             str_amparticipant_attendingam = new String[json_array_amparticipants.length()];    
                             str_amparticipant_attendingpm = new String[json_array_amparticipants.length()];
    

    You’re recreating the arrays every time you go into the loop, erasing any previous values.

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

Sidebar

Related Questions

I have a string which has say 3000 characters, now I want to split
I have a 2-D array in R which represents value data for a grid
I have a txt file which has data in the below format: int string
I get this error, while I'm testing the code below: You have an error
I have this query and I get error Operand should contain 1 column(s), whats
I have created Controller Attribute and would like to read SessionId but get error
So I'm trying to update my GridView, and I get this error: You have
I have a page called ..hi i get this error when visiting the page.
I get this error when trying to link a win32 exe project. I have
I get this error by downloading an image by HTTP. I have looked at

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.