Thursday, September 30, 2010

Re: [android-developers] Setting/Passing values

On Thu, Sep 30, 2010 at 6:09 PM, rb <rbsata@gmail.com> wrote:
> How do you set/pass values from one screen (activity) to another?

That depends on the nature of the "values".

> When you press the menu button, you get the options menu.  If you
> select "Setup", then
> it will display the setup screen.  Now what I need to do is take the
> values from the setup screen (radio button and text values)
> and place them in the main screen so that when you exit the setup
> screen and go back to the main
> screen, you can take those values and use them in your main code.

That sounds like:

-- the "setup screen" should be a PreferenceActivity
-- the main activity should load its preferences in onStart(), or use
a preference-change listener, to pick up the changed preferences

If, for whatever reason, you want to collect preferences by means
other than the preferences system, and so your setup screen is just an
ordinary activity, have the main activity use startActivityForResult()
and have the setup screen use setResult() to pass back the data via
Intent extras.

However, I really recommend that preferences be collected by the
preference system wherever possible. People bitch and moan about how
Android applications have no consistent UI. Preferences is one of the
few places where Android makes it relatively painless to offer a
consistent UI.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate