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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:01:26+00:00 2026-05-31T17:01:26+00:00

I’m trying to build expandableList with SimpleCursorTreeAdapter but my list does not make groups,

  • 0

I’m trying to build expandableList with SimpleCursorTreeAdapter but my list does not make groups, it repeats every child element as group element.

My datas are formed as KEY_ROWID ,KEY_NAME , KEY_EMAIL ,KEY_ILID ,KEY_KURUMID ,KEY_BOLGEID


my datas:

(db,"Asli", "asli@gmail.com", 1, 1, 1); 
(db,"Osman Can", "osman@gmail.com", 1, 1, 1); 
(db,"Abuzer Kadayif", "kadayif@gmail.com", 1, 2, 1); 

(db,"Emre", "emre@gmail.com", 1, 3, 2); 
(db,"Deniz", "deniz@gmail.com", 1, 4, 2); 

(db,"Simon Garfunkel", "simon@gmail.com", 1, 5, 0); 
(db,"Eric Clapton", "eric@gmail.com", 1, 6, 0); 
(db,"Neil Young", "neil@gmail.com", 1, 5, 0); 

And This is my code:

String sqlString = "SELECT * " + " FROM " + Items.DATABASE_TABLE;

        Cursor mCursor = db.rawQuery(sqlString, null);

        SimpleCursorTreeAdapter mAdapter = new SimpleCursorTreeAdapter(this,
                mCursor, R.layout.row, R.layout.exprow,
                //createGroupList(), 
                new String[] { Items.KEY_BOLGEID },
                new int[] { R.id.txtItem },
                R.layout.exprow, R.layout.exprow,
                new String[] { Items.KEY_EMAIL,Items.KEY_NAME }, new int[] { R.id.dscItem, R.id.manuItem }) {

            @Override
            protected Cursor getChildrenCursor(Cursor groupCursor) {

                String tempGroup = groupCursor.getString(groupCursor
                        .getColumnIndex(Items.KEY_BOLGEID));

                DbHelper dbh = new DbHelper(BrowseActivity.this);
                SQLiteDatabase db = dbh.getWritableDatabase();

                String sqlString = "SELECT " + Items.KEY_ROWID + ", "
                        + Items.KEY_EMAIL + ", " + Items.KEY_NAME + ", "
                        + Items.KEY_KURUMID + ", " + Items.KEY_BOLGEID + ", "
                        + Items.KEY_ILID + " FROM " + Items.DATABASE_TABLE
                        + " WHERE " + Items.KEY_BOLGEID + "= "  + tempGroup 
                        ;
                Cursor mCursor = db.rawQuery(sqlString, null);

                return mCursor;

            }


        };

        browseView.setAdapter(mAdapter);

    }

My result should be:

Group 1:
(db,"Asli", "asli@gmail.com", 1, 1, 1); 
(db,"Osman Can", "osman@gmail.com", 1, 1, 1); 
(db,"Abuzer Kadayif", "kadayif@gmail.com", 1, 2, 1); 
Group 2:        
(db,"Emre", "emre@gmail.com", 1, 3, 2); 
(db,"Deniz", "deniz@gmail.com", 1, 4, 2); 
Group 3:        
(db,"Simon Garfunkel", "simon@gmail.com", 1, 5, 0); 
(db,"Eric Clapton", "eric@gmail.com", 1, 6, 0); 
(db,"Neil Young", "neil@gmail.com", 1, 5, 0);

But it is
3 times group 1
2 times group 2
3 times group 0

And I tried to change sql of groupCursor, but it crashes.

  • 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-31T17:01:30+00:00Added an answer on May 31, 2026 at 5:01 pm

    You need to change your first SQL statement to only return the groups you want once. Right now you are getting it for each record, so the adapter if giving you a group for each one. Change your SQL to:

    String sqlString = SELECT DISTINCT " + Items.KEY_BOLGEID + " AS _id FROM " + Items.DATABASE_TABLE;
    

    That will get you one instance of each item you wish to group on (and set it to the _id column, which is required for the adapter).

    Then just use new String[] { _id } in the group portion of your adapter call.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but

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.