TabWidget, TabSpec programmatically and refresh data within the tabs from onResume

by David G. » Tue, 20 Oct 2009 19:27:11 GMT


Sponsored Links
 hi there.

I'm a newbie using android sdk.
In my first application, I have a TabWidget which is defined into the
xml. It can contains several tabs, created programmatically. The
number of tabs depends of the data coming from a web service.

I want to reload the data each time the application is displayed. To
do that, I reimplemented the onResume on the activity. A background
task is launched to preform the refresh of the data then, to recreate
the tabs (into a runOnUiThread method).

The problem here is I don't know if I have to recreate the tabs OR to
refresh only the data of the views inside the tabs.

For now, I recreate the tabs but I often got some exceptions and I'm
pretty sure it is the wrong way to do that.
For example, I leave the application with the second tab open, when I
come back, the reload is perform and I got an exception. This
exception is not there if I were on the first tab. I can try to
"clean" the tabs or "remove" the views but I guess is weird to do
that.

So what is the best way to implement tabs and data refresh ?

Thanks a lot!
David
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Custom Drawable (Gradient) based on Theme

I would like to apply a different drawable (or different colors to my
gradient drawable), based on the Theme.  Is this possible?

-- 

2. Detecting enter key from virtual keyboard

I've got code in a view that launches the virtual keyboard as follows:

InputMethodManager imm = (InputMethodManager) context.getSystemService
(Context.INPUT_METHOD_SERVICE);
boolean shownKeyboard = imm.showSoftInput(this, 0);

I'm picking up key presses from it fine except for the enter key,
which never gets detected.

Solutions that *don't* work include:

onKeyUp/onKeyDown/onKeyMultiple/dispatchKeyEvent in the view/activity
dispatchKeyEventPreIme/onKeyPreIme in the view

These methods don't get called when the enter key is pressed on the
virtual keyboard.

How can I trap and react to the enter key?

-- 

3. Extend "Edit Contact" view with new field

4. listactivity xml

5. Interpretation

6. UTF-8 encoding problem

7. How to Load My Local Asset Html File ? Content is in Hebrew