I don't know anything about datasetobserver, and I'm sure there are
better ways to do this, but a hack that works for me is to keep track
of when you need to refresh the list.  If the user creates a new entry
while in the expandable list, then I launch that as an activity for a
result, and if it comes back that they did indeed add or edit a
record, then I re-load the activity that hosts the expandable list.
I'm sure that is inefficient but so far with some pretty big lists,
it's working really well.  It even tracks which tab the user was on so
they return to where they were. Of course the list is now fully
collapsed, although I think there is a way to track that and then re-
expand the group and scroll the list if  you wanted to do that.

Other things I tried that didn't work but maybe give you some ideas,
if you host the list in a tab then you can set the tab to auto-
refresh.  That only seems to work when the user switches tabs.

There's the managecursor command (or something like that) which is
supposed to keep the list's cursor adapter current as the database
changes, and that seemed to work just fine until things got
complicated with multiple tabs and activities.

On Jul 29, 1:45 pm, Beth <[email protected]> wrote:
> Hello good people,
>
> I have an expandable list view with a static array for the group data
> and an SQLite database for the child data.  It is implemented with the
> BaseExpandableListAdapter and works great, except, when I edit the
> database to delete or add children to the list I do not see the
> changes onscreen.  It looks like I can use the registerDataSetObserver
> method to notify the adapter and expandable list of a data change.
> What I have to do in the callback to make Android redraw the list
> after data changes is what I need to know.  Can I do it?
>
> Documentation on this part of the SDK is a bit sparse and expandable
> list view example code is not a good match.  Can anyone offer advice
> on how to use a DataSetObserver? It feels like I have to switch over
> to a Cursor type adapter.  Any insight is most welcome.
>
> Pardon the double post to Android Beginners.
> Best regards,
> Beth
>
> On Jul 27, 2:48 pm, Beth Mezias <[email protected]> wrote:
>
>
>
> > Hi there,
>
> > Here is the situation.  In a TabbedView, one of three tabs is an
> > ExpandableListViewActivity.  My application is using SQL Lite to store the
> > data bound to the ExpandableListView.  When I change the SQL Lite data in
> > another activity, I need to refresh the ExpandableListView and show the new
> > data.  If I am drawing the tab for the first time after adding new data, the
> > list shows correctly after the tab switch.  If I am in the
> > ExpandableListViewActivity when I add new data to the list or edit existing
> > data, then I do not see the change.  In this case, when I exit the
> > application and restart, I see the modified data was stored in SQL Lite as
> > expected.  Can anyone suggest how I might get the tab to redraw the list?
>
> > The partially working code looks like this:
> >     @Override
> >     protected void onActivityResult(int requestCode, int resultCode, Intent
> > intent) {
> >         super.onActivityResult(requestCode, resultCode, intent);
> > //stuff deleted
> >         if((requestCode == EDITOR) && resultCode==RESULT_OK) {
> >             tabs.setCurrentTab(1);
> >             tabs.getCurrentView().invalidate();
>
> >         }
>
> > }
>
> > The constructor for the list adapter is where I execute the code to populate
> > the groups and children.  Do I want to drop and create a new list adapter?
> > That seems like a waste of perfectly good rows.  Is it something I should do
> > in the ExpandableListViewActivity, rather than the TabHost?  The fact that
> > this is an expandable list is probably irrelevant; I am stuck where an
> > object on the screen that has changed is not redrawn automatically.
> > Your help is deeply appreciated.
>
> > Best regards,
> > Beth
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to