Thanks for shedding some light on this issue.

Here's some of my code:

--------------------------- Main ------------------------------

package com.calculator;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Calculator extends Activity {

    private static final int MY_SETUP = 0;
    private static final int MY_ABOUT = 1;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

-- code of main calculation --

    // options menu

    // Called only the first time the options menu is displayed.
    // Create the menu entries.
    // Menu adds items in the order shown.
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        menu.add("Setup")
        .setIcon(android.R.drawable.ic_menu_preferences);
        menu.add("About")
        .setIcon(android.R.drawable.ic_menu_info_details);
        return true;
    }

    // handle menu selected
    public boolean onOptionsItemSelected(MenuItem item){

         if (item.getTitle().equals("Setup")){
            Intent intent = new Intent(this,
com.calculator.setup.class);
            startActivityForResult(intent, MY_SETUP);
            return true;
         }

         if (item.getTitle().equals("About")){
         Intent intent = new Intent(this, com.calculator.about.class);
         startActivityForResult(intent, MY_ABOUT);
            return true;
         }
        return false;
    }
}
--------------------------- Setup ------------------------------

package com.calculator;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Arrays;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;


public class setup extends Activity {
        public Boolean changeGroup = false;
        public int fps;
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                setContentView(R.layout.dialogsetup);

-- code of setup  Here you check for various clicks for radio and
regular buttons. --
}


I was going to save and read the data from a file which would be
stored
in the phones default applications directory as one file.

Not sure how you would use the preference activity for storing name/
values as
I need to store and retrieve 6 different items.

An example would be:
radioButtonValue = "30"
editTextValue = "5:02"

I need to take those values and use them in the main screen for either
calculation or display.

Any chance you could reply with some code on how I could utilize the
preferences activity
from the code I have provided?


On Sep 30, 4:14 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> On Thu, Sep 30, 2010 at 6:09 PM, rb <rbs...@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/commonsguyhttp://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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to