I know there are multiple snippets of information about multiple
Spinner activities, but I hope mines will be a bit more simplistic in
nature.
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:
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()
{ <--- I'm
currently researching how to implement this flow
public void onItemSelected
(
AdapterView parent, View view, int position, long id) {
//How to refer to selected item.
String selectedItemString = parent.getSelectedItem();
}
**************************************************************************************************************************
And here's my Array.xml
<resources>
<string-array name="states">
<item>Jupiter</item>
<item>Pluto</item>
<item>Mars</item>
<item>Neptune</item>
<item>Earth</item>
</string-array>
</resources>
*****************************************************************************************************************************
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.
~M~
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---