>From what I gather you're trying to grab a value from the spinner and
move it to another Activity (I assume within the same program?). If
this is not something you need to do and retain a history of, I would
suggest either just adding the data as an extra to the Intent for the
Activity (Option 1) or you can create a SharedPreference and send the
information that way (Option 2)
Option 1:
Intent intent = new Intent(this, Activity.class);
intent.putExtra("NameOfExtraData", ExtraData);
startActivity(intent);
Option 2:
private static final string PREFS_NAME = "com.yourapp.namespace";
\\Store Preference
public static void StoreData(Context context, String data){
SharedPreferences.Editor prefs =
context.getSharedPreferences(PREFS_NAME, 0).edit();
prefs.putLong("NameOfDataToStore", data);
prefs.commit();
}
\\Retrieve Preference
public static String RetrieveData(Context context){
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME,
0);
String ID = prefs.getString("NameOfDataToStore", "Default value if
no preference exists");
}
On Apr 8, 1:14 am, Nubh <[email protected]> wrote:
> I need to know how to store the values when we click the save button.
> But the value needs to be stored individually for the
> Spinner, please see.. and whether to use prefrences or not. Please
> suggest and if any refrence code which I can look would be
> very helpful. I am mailing with the context or the pupose of my
> project, please help to make the code work. There's a screen shot
> where u can acutally look how the UI looks.
>
> Need to store values here and pass to other activity, this is the
> actual code where we need to store the values to the phone no 1,
> please help.. Here I am printing a toast on the screen but what i
> need
> to do the contact I select from the list i.e. from
> "parent.getContext()"
> method is calling People._Id which captures the ID of the phonebook
> entry and which is needed to import the values in the list, so my
> motive is to store the number and pass it to the dialer or
> 'ACTION_CALL'.
>
> Thanks
> NUBH
>
> // This is the method for first spinner and code block for first value
> public class MyOnItemSelectedListener implements
> OnItemSelectedListener
> {
> public void onItemSelected(AdapterView<?> parent,
> View view, int pos, long id)
> {
> // Code block for first value
> Toast.makeText(parent.getContext(),
> "The Person is " +
> parent.getItemAtPosition(pos).toString(),
> Toast.LENGTH_LONG).show();
> }
> public void onNothingSelected(AdapterView<?>
> parent)
> {
> // Do nothing.
> }
> }
--
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en