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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:12:21+00:00 2026-05-28T01:12:21+00:00

I am not exactly clear on how to implement ExpandableList as array resource instead

  • 0

I am not exactly clear on how to implement ExpandableList as array resource instead of hard-coded array (by replacing an existing hard-coded array with XML layout). Here is my strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">adaptor_ExpandableList1</string>

    <string name="expandable_list_sample_action">Sample action</string>
    <string-array name="Groups">
        <item>People Names</item>
        <item>Dog Names</item>
        <item>Cat Names</item>
        <item>Fish Names</item>
    </string-array>
    <string-array name="People Names">
        <item>Arnold</item>
        <item>Barry</item>
        <item>Chuck</item>
        <item>David</item>
    </string-array>
    <string-array name="Dog Names">
        <item>Ace</item>
        <item>Bandit</item>
        <item>Cha-Cha</item>
        <item>Deuce</item>
    </string-array>
    <string-array name="Cat Names">
        <item>Fluffy</item>
        <item>Snuggles</item>      
    </string-array>
    <string-array name="Fish Names">
        <item>Goldy</item>
        <item>Bubbles</item>
    </string-array>
</resources>

Here is what I changed in the Java file:

public class MyExpandableListAdapter extends BaseExpandableListAdapter {
    // Sample data set.  children[i] contains the children (String[]) for groups[i].
    private String[] groups = getResources().getStringArray(R.array.Groups);
    private String[][] children = {getResources().getStringArray(R.array.People Names),
        getResources().getStringArray(R.array.Dog Names),
        getResources().getStringArray(R.array.Cat Names),
        getResources().getStringArray(R.array.Fish Names)
    };

Of course R.array.xxx Names does not work. So how can I correct the problem when there are statements in R.java such as this: public static final int Cat Names=0x7f040003;.
There must be a rule for this but I don’t know it yet.

Browsing through numerous examples, I think I also need to have group and child layout files and perhaps a main layout file (I think I know how to implement them if I need to). Is this correct?

Thanks in advance for your help!

  • 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-05-28T01:12:22+00:00Added an answer on May 28, 2026 at 1:12 am

    you have space in the name of string array

    remove space from “people names” and other string array names.

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

Sidebar

Related Questions

I often hear/read about interfaced based programming but I am not exactly clear on
Just a foreword: I'm not exactly clear on how a RNG actually works. If
Not exactly about programming, but I need help with this. I'm running a development
Not exactly sure how to look this up, but I'm not finding the solution
This is not exactly a programming question, but it's highly related. We are writing
I'm not exactly sure how to ask this question really, and I'm no where
My question is not exactly the same as this one (it's not theoretical, there
If the itemcount property does not exactly match the number of indexed rows is
I have a few tables that have similar fields but not exactly the same.
The question title is a bit strange because I'm not exactly sure how to

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.