I'm building an app in which the first activity contains a spinner with strings "Red", "Yellow", "Blue" and "Green". When the user selects a spinner item, the second activity's background will be that color. I'm having issues with passing that value from the MainActivity class to the Display class.
In case you wonder how to retrieve the spinner value :
String pickedColor = yourSpinner.getSelectedItem().toString();
In your first Activity, when building intent do something like :
Intent intent = new Intent(MainActivity.this, DisplayActivity.class); intent.putExtra("COLOR_KEY", pickedColor); startActivity(intent);
Then in your second activity :
String color = getIntent().getStringExtra("COLOR_KEY");
Then do whatever you need :)