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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:49:46+00:00 2026-06-13T02:49:46+00:00

I have some part of an android app here which crashes for no apparent

  • 0

I have some part of an android app here which crashes for no apparent reason.

RL0 happens to be some LinearLayout defined in XML which already contains some other irrelevant stuff. To be honest with you, I’ve mostly worked with C++ so I might not initially know much about why some things are done significantly different in android, but I’m putting effort. Any help on how I can fix that crash?
Error message states NullPointerException.
Thanks.

public class Osteoporoza extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_osteoporoza);
        LinearLayout RL0=(LinearLayout)findViewById(R.id.RL0);        

        page[] pages=new page[10];
        RL0.addView(pages[0].pageLL0);//doesn't crash without this line, yet i need to have some way of adding n objects that follow a pattern, i.e. a class.

class page
{
    public LinearLayout pageLL0;
        public ScrollView pageUpperScroll1;
            public TextView pageTextView2;
        public ScrollView pageLowerScroll1;
            public LinearLayout pageAnswerButtonLL2;
                public Button AnswerButton3_1;
                public Button AnswerButton3_2;
                public Button AnswerButton3_3;
                public Button AnswerButton3_4;

    page()
    {
        pageAnswerButtonLL2.addView(AnswerButton3_1);
        pageAnswerButtonLL2.addView(AnswerButton3_2);
        pageAnswerButtonLL2.addView(AnswerButton3_3);
        pageAnswerButtonLL2.addView(AnswerButton3_4);

        pageLowerScroll1.addView(pageAnswerButtonLL2);
        pageUpperScroll1.addView(pageTextView2);

        pageLL0.addView(pageUpperScroll1);
        pageLL0.addView(pageLowerScroll1);
    }
}
  • 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-13T02:49:47+00:00Added an answer on June 13, 2026 at 2:49 am

    All elements in an Object array are null by default.

    I.e. when you create the array:

    page[] pages = new page[10];
    

    you are only setting the size of the array but not setting any instances within the array itself so every element will be null. To instantiate each element you need to use:

    for (int i=0; i < pages.length; i++) {
       pages[i] = new page();
    }
    

    Note Java naming conventions show that class names start with an uppercase letter, for example

    Page[] pages = new Page[10];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Add Contact App which in some part, it shows the contacts
I have an app in android in which I return some data from facebook
I have some .csv files which I'm using as part of a test bench.
I have some accent issues in a shopping cart script. Here's a part of
I have a linux vm which is our testing machine. as part of some
For some reason I have a very ugly orange part of a border around
Story: I have a link which has some text. A part of the link
I am writing an Android app and need some help. I have a string
I have an Android app that takes some pictures, re-sizes them and sends them
I am working on an android app in which I am seeing some disparity

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.