Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i am very new at this android and Java in generel. However, i do know c++, php among others, but this s*** is just not working for me, so i hope you can help me.

I guess it is a pretty simple and easy answer, however i cannot seem to get it to work. I have tried using spinners in the way the official "android" help says, but then i do not seem to be able to save the data and transfer it to another class.

So my code is this:
package com.example.handballstats;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class NewGameScreen extends Activity {

    ArrayAdapter<String> HomePlayer1Adapter;
    ArrayAdapter<String> AwayPlayer1Adapter;

int [] valueHomePlayer1Array = {0,25};
int [] valueAwayPlayer1Array = {0,25};

Spinner HomePlayer1Spinner;
Spinner AwayPlayer1Spinner;

    protected void onCreate(Bundle savedInstanceState) {

        HomePlayer1Spinner = (Spinner) findViewById(;
        AwayPlayer1Spinner= (Spinner) findViewById(;



    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;

    public void loadHomePlayer1Range() {


    public void loadAwayPlayer1Range() {

    public void game_start (View view){
        Intent game_start_intent = new Intent(NewGameScreen.this, GameStartScreen.class);
        game_start_intent.putExtra("Data1", valueHomePlayer1Array);
        game_start_intent.putExtra("Data2", valueAwayPlayer1Array);


I want the two spinners to have values from 0-25. Then i want to be able to save these values and import them in a new class using something like:
Private String data1;
Private String data2;
Private int data3;

Bundle extras = getIntent().getExtras();
if (extras != null) {
    data1 = extras.getString("Data1");
    data2 = extras.getString("Data2");
    data3 = extras.getInt("Data3");
// other code
Intent myIntent = new Intent(Activity2.this, Activity3.class);
myIntent.putExtra("Data1", data1);
myIntent.putExtra("Data2", data2);
myIntent.putExtra("Data3", data3);

Can someone help me, with what i am doing wrong in the first activity?

1 solution

I think the problem lies in the way you were trying to pass array object between activities as intent extras, unfortunately that would not work. You have to implement serializable or make use of parcelable class, find out more here: android-parcel-data-to-pass-between-activities-using-parcelable-classes[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900