What I am trying to do is give a user a selection of planets by means of a Spinner interface. When user chooses said planet, they will be directed to a linear layout embedded with the planet's image. [Spinner -> Spinner Array -> Spinner Selection -> Image]
Here's my java:
Using java Syntax Highlighting
- package com.test.screen;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.ArrayAdapter;
- import android.widget.Button;
- import android.widget.Spinner;
- public class screen2 extends Activity
- {
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.screen2);
- //Begin Spinner Function
- Spinner s = (Spinner) findViewById(R.id.spinner1);
- ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
- this, R.array.planets, android.R.layout.simple_spinner_item);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- s.setAdapter(adapter);
- //New Stuff: Put activity to do when something is selected.
- s.setOnItemSelectedListener(
- new OnItemSelectedListener(){
- public void onItemSelected(
- AdapterView parent, View view, int position, long id) {
- //How to refer to selected item.
- String selectedItemString = parent.getSelectedItem();
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
**************************************************************************************************************************
And here's my Array.xml
Using xml Syntax Highlighting
- <resources>
- <string-array name="states">
- <item>Jupiter</item>
- <item>Pluto</item>
- <item>Mars</item>
- <item>Neptune</item>
- <item>Earth</item>
- </string-array>
- </resources>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
*****************************************************************************************************************************
I appreciate any help that can be offered. It goes without saying I am new, but I humbly ask upon the help of the java/Android gurus.
~A~

