I need to share an id key (int) between three ListActivities hosted in
a TabActivity.

I have a TabActivity with three tabs that each start ListActivities
via intents like this:

...
tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("Recipes")
                .setContent(new Intent(this, RecipeList.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator("Ingredients")
                .setContent(new Intent(this, IngredientList.class)));
tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("Method")
                .setContent(new Intent(this, MethodList.class)));
...

These three activities use a content provider with three normalised
tables:

RecipeList uses the Recipes table:           | _ID | RecipeName |
IngredientList uses the Ingredients table:   | _ID | RecipeID |
IngredientText |
MethodList uses the Methods table:          | _ID | RecipeID |
MethodText |

The RecipeID column in the Ingredients and Methods tables refers to
the _ID column of the Recipes Table, thus linking ingredients and
methods to the relevant recipe.

So what I plan to do is when a row is selected in the RecipeList tab,
store the _ID somewhere accesible by IngredientList and MethodList
activities. Then when IngredientList or MethodList tabs are selected a
cursor query is made using the stored id in a where statement, thus
only displaying ingredients/methods that have a RecipeID value
matching the _ID of the selected recipe on RecipeList.

The only real solution I have come up with so far is using a static
int in the tabhost activity that the other activities can all read,
but this seems very messy and would require that only one instance of
any of the activities is created.

I'm sure there must be a neat way to do this with intents or
something, does anyone have any advice or examples?



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to