private ListGame_Mode_List for (int i=0;i < Game_Mode.length ;i++) { // Populate the Game_Mode List Game_Mode_List.add(Game_Mode[i]); } // Put the Game_Mode_List to an Addapter and set addapter tpye ArrayAdapter Game_Mode_Addapter = new ArrayAdapter ( this, android.R.layout.simple_spinner_dropdown_item, Game_Mode_List); Game_Mode_Addapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item ); // Create Spinner and attach the addapter to it. Spinner Game_Mode_Spinner = new Spinner(this); Game_Mode_Spinner.setAdapter(Game_Mode_Addapter); // The listener will listen the change. arg2 is the item selected Game_Mode_Spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { myGameMode = String.valueOf(arg2); } @Override public void onNothingSelected(AdapterView arg0) { myGameMode = "1"; } } );
Thursday, November 18, 2010
How to use Spinner
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment