Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh tab listview from parent activity
    primarykey
    data
    text
    <p>Hi I have an application which after login, loads a main activity which contains a tabhost with 3 tabs containing listviews. Each tab is populated via sqlite + custom adapter. The database is initially populated via xml data (sync'd asynchronously to the sqlite database).</p> <p><strong>My problem:</strong> I want to allow allow manual syncing of the sqlite database with XML data, which then updates the current tab listview. I have the asynchronous thread working fine to do the background update of the database. What i can't figure out is how to force a refresh of the current tab's listview. The problem is i don't know how to access a sub activity within the tabhost from the parent activity. </p> <p>I'm fairly sure notifyDataSetChanged() is what i need but i can't figure out how to access the tab's activity > adapter to do this. How do i access a sub activities adapter in order to call notifyDataSetChanged()? The parent (containing) activity has the button which will be used to refresh the tabhost's listview.</p> <p><strong>An alternative</strong>: i could try is broadcasting an intent from my background thread's onPostExecute() callback. ie, when it finishes updating the database with xml data i have my tab receive the broadcast and trigger it to refresh via notifyDataSetChanged()... but this is probably NOT how broadcast/receive intents are designed is that right?? ie, communicating between a activity and contained tab's listview activity?</p> <p>This is my 2nd post on stack overflow I hope I've been clear in my explanation. Thanks for any help or advice you can provide</p> <p><strong>EDIT (16-Jan-2012):</strong> Been a long time since I worked on this issue. I originally used a solution of broadcasting an intent and consuming it in the child activity. BUT I've since taken the advice from many others (and you should too)! and instead stopped using Activities inside tabs. I'm now using views within the tabs. This works MUCH better and cleaner. </p> <p>Apart from the code getting too cumbersome, I was also getting weird "Database not closed" type errors when going between Activities also when rotating the devide from portrait/landscape. Views within tabs instead of activities fixed many issues and I'm sure its better on resource usage. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload