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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:02:55+00:00 2026-06-12T03:02:55+00:00

I am trying to create an ExpandableListView dynamically in my application. The parent rows

  • 0

I am trying to create an ExpandableListView dynamically in my application. The parent rows display the dates of the next 7 days and I retrieve the children from a web-service. But, fetching and displaying the children are not my problem. I am facing trouble in displaying the parent rows dynamically. I need to display the dates of the next 7 days in the parent rows.

I declared this empty array of strings globally.

private String[] parent = new String[7];

Then, inside onCreate(), I used this code to create the parent array contents.

Calendar cal = Calendar.getInstance();
    String strdate = null;
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");

    int i;
    for(i=0;i<7;i++)
    {

        if (cal != null) {
            strdate = sdf.format(cal.getTime());
            }
            parent[i] = strdate;
           cal.add(Calendar.HOUR_OF_DAY, 24);
    }

But, the activity gives a NullPointerException at MyExpandableListAdapter.getGroupView().

(Maybe because the parent array has not be initialized initially ?)

because the code works when I declare the parent array initally as

private String[] parent = new String[] {"","","".....}; 
  • 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-12T03:02:57+00:00Added an answer on June 12, 2026 at 3:02 am

    My solution : Static Block was the answer to it. I put the code to create the parent array contents inside a static block instead of onCreate() and it works like a charm now.

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

Sidebar

Related Questions

I trying create a class derivated from System.Web.UI.Page and in override Render i set
I am trying create a small web application that allows a user to login
I am trying to create an ExpandableListView with selectable elements(children) so that the selections
I'm trying create simple application in C++. This application has to read from file
I trying create iis7 web application by msbuild community tasks and set property Enabled
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to create custom background selector for my ExpandableListView. It works fine
I'm trying create an immutable object and initialise it from xml config file in
I'm trying create a RCP Application with Eclipse, but I can't get past the
In my android application I am trying create persistent connection for downloading images. Here

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.