First, you'd need to get the id of the element. It's in a list, so
probably this setting an OnItemClickListener to your list
(setOnItemClickListener method). From there you have access to the id
that was given to the item when the list was created which is probably
what you want. That happens inside onItemClick of the
OnItemClickListener. In this method, put your intent and
startSubActivity call. Create a Bundle and put the id in the bundle,
then add it to the intent. It'd be something like this:

Intent intent = new Intent(this, TeaTimer.class);
Bundle bundle = new Bundle();
bundle.putLong(ID_TAG, id);
intent.putExtras(bundle);
startSubActivity(intent, ACTIVITY_CREATE);

Disclaimer: I didn't test the code above, it might not even compile,
but it's close to what you want.

And then in the onCreate of your TeaTimer Activity, you get the Bundle
with getIntent().getExtras() and can get the value with
bundle.getLong(ID_TAG).

On Mar 25, 12:26 pm, MobileBen <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have two activities. Activity1 displays a list with different items,
> Activity2 is a timer.
> Each item (in Activity1) has a name, and a special time saved in the
> database.
> Based on the time of each item the timer in Activity2 has to be set.
>
> For example when I select item4 in Activity1 which has a time of 2
> min, the timer in Activity2 should be initialized with 2 minutes.
>
> So I need the ID form the element I selected (in Activity1) in
> Activity2, because ID is my key element in the database and the query
> to get the minutes of the element takes place in Activity2.
>
> Can anybody tell me how I get the ID from the element which I selected
> in Activity1 to Activity2 that I can use this ID in Activity2?
>
> I hope that everybody can understand my question, it is hard for me to
> explain.
>
> Here is the call of Activity2 (onCreate) taken place in Activity1.
>
> private void runTheTimer() {
>         Intent i = new Intent(this, TeaTimer.class);
>         startSubActivity(i, ACTIVITY_CREATE);
>
>     }
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to