Spinner Help

Put your problem here if it does not fit any of the other categories.

Spinner Help

Postby Dladu » Wed May 06, 2009 1:58 pm

Hello, I am new to android and I am trying to make an Episode List type program for information on various episodes . I am trying to create two spinners "Season" and "Episode", The first spinner defining the seconds items (as there is a different amount of episodes per season). Also then I need it to retrieve the two inputs when submit is hit and direct the program to the right episode, so far what I have tried from different tutorials online hasn't seemed to work. Heres my spinners in the java file so far..


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.project.topgear;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.os.Bundle;
  8.  
  9. import android.view.View;
  10.  
  11. import android.view.View.OnClickListener;
  12.  
  13. import android.widget.ArrayAdapter;
  14.  
  15. import android.widget.Spinner;
  16.  
  17.  
  18.  
  19.  
  20.  
  21. public class Season extends Activity implements OnClickListener {
  22.  
  23.         public void onClick(View v) {
  24.  
  25.                 switch (v.getId()) {
  26.  
  27.                 }
  28.  
  29.         }
  30.  
  31.         @Override
  32.  
  33.         public void onCreate(Bundle savedInstanceState) {
  34.  
  35.                     super.onCreate(savedInstanceState);
  36.  
  37.                         setContentView(R.layout.arrays);
  38.  
  39.                        
  40.  
  41.                         Spinner s = (Spinner) findViewById(R.id.spinner);
  42.  
  43.                     ArrayAdapter adapter = ArrayAdapter.createFromResource(
  44.  
  45.                     this, R.array.seasons, android.R.layout.simple_spinner_item);
  46.  
  47.                     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  48.  
  49.                     s.setAdapter(adapter);
  50.  
  51.                    
  52.  
  53.                    
  54.  
  55.                     Spinner s1 = (Spinner) findViewById(R.id.spinner01);
  56.  
  57.                     ArrayAdapter adapter1 = ArrayAdapter.createFromResource(
  58.  
  59.                     this, R.array.episodes, android.R.layout.simple_spinner_item);
  60.  
  61.                     adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  62.  
  63.                     s1.setAdapter(adapter1);
  64.  
  65.  
  66.  
  67.                
  68.  
  69.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

Any help would be appreciated
Thanks

Edit: Searched a bit and found this code snipit:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  s.setOnItemSelectedListener(
  3.  
  4.                     new OnItemSelectedListener() {
  5.  
  6.                            public void onItemSelected(
  7.  
  8.                                    AdapterView parent, View view, int position, long id) {
  9.  
  10.                                                
  11.  
  12.  
  13.  
  14.                                          }
  15.  
  16.  
  17.  
  18.                                          public void onNothingSelected(AdapterView parent) {
  19.  
  20.                                               setDefaultKeyMode(DEFAULT_KEYS_DISABLE);
  21.  
  22.                                          }
  23.  
  24.                       });
  25.  
  26.  
Parsed in 0.048 seconds, using GeSHi 1.0.8.4


I am struggling to find what to put in the onItemSelected void though, also if I could incorperate the onItemSelected with the other spinner which both would be controlled by the submit button.
Dladu
Freshman
Freshman
 
Posts: 4
Joined: Wed May 06, 2009 1:47 pm

Top

Postby Dladu » Tue May 12, 2009 9:48 pm

Bump :P
Dladu
Freshman
Freshman
 
Posts: 4
Joined: Wed May 06, 2009 1:47 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests