开发者

Sending data between activities within my app?

I have a TabActivity, and the tabs point to sub activities. Is there a way I can send a 'message' to those child activities? I just want to pass a string across, not sure if this is possible.

I have some data being fetched by the parent TabActivity, and the child tabs can't开发者_JAVA技巧 do anything useful until the parent is done fetching. When fetching is complete, I'd like to pass that data to the child activities so they can do something useful with it.

Notmally I'd set the data to be passed in the Intent when first creating the activity, but in this case I can't do that.

Thanks


I have a TabActivity, and the tabs point to sub activities.

Don't do that. All you are doing is making your life harder and making your application take more memory, CPU time, and battery life.

Use Views as the contents of the tabs, instead of activities, and you will not have communication difficulties of this nature.

Here is a sample project using Views as the contents of tabs.


I would say you have 2 options, either put for instance static view before your tabactivity and display a progress bar while doing your fetching and then display your tabs with the full content, or fetch your content, store it in a variable and reload the whole activity by doing an intent on itself.

These are the easiest way I would do it... does it make sense?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜