Droidman
Droidman

Reputation: 11608

passing objects to another activity

Situation

In my alarm clock app I start a NewAlarmActivity by clicking a button. After the user has made all the selections, alarm gets set and `finish() is called.

The matter

I create a new LinearLayout object with images and text within it. That layout must be added to the screen of previous activity (to another LinearLayout placed inside a ScrollView) so the user is able to see the alarm set. Somehow I have to pass that LinearLayout object to the first activity and tell it to receive and add the object to the screen.

How can I do that?

Upvotes: 0

Views: 132

Answers (2)

shkschneider
shkschneider

Reputation: 18253

You just need to read some documentation about startActivityForResult().

BTW, IMHO, you should not transport your LinearLayout object between activities, that's ugly.

How to manage `startActivityForResult` on Android?

Starting Activity And Getting Result

This has been asked countless times...

Upvotes: 2

jtt
jtt

Reputation: 13541

No You don't have to do this. Try the approach of storing your data into a database and then when going into that Activity, build your layout according to the data you have. This is a much better way than passing a layout from one Activity to antoher.

Upvotes: 1

Related Questions