Spinner problems

by Danny » Sun, 15 Mar 2009 06:48:59 GMT


Sponsored Links
 Hi all:
I have some problems with spinners
1. I have 3 spinners: type_spinner, from_spinner, to_spinner.

Problem: from_spinner and to_spinner does not display correctly what
are selected AFTER switching to landscape mode ( or portrait mode ) by
pressing Ctrl + F11.
The position selected of from_spinner and to_spinner are correct after
switching ( Tested ), BUT the values displayed on the spinner are
WRONG after switching( resetted to pos# 0 ).

Example:

Before switching

Type Spinner:  TYPE2
From_spinner:   CALIFORNIA ( pos#2 )
To_spinner:    NEWYORK  (pos#3)

After switching ( Ctrl + F11 )

Type Spinner:  TYPE2
From_spinner:  OREGON ( pos# 0 ) - If open the spinner(click), it is
selected at pos#2
To_spinner:    OREGON ( pos#0 ) - If open the spinner, it is selected
at pos#3)



Here is the code:

private Spinner type_spinner;
private Spinner from_spinner;
private Spinner to_spinner;

type_spinner = (Spinner) findViewById(R.id.type_spinner);
        ArrayAdapter<CharSequence> type_adapter =
ArrayAdapter.createFromResource(this, R.array.types,
android.R.layout.simple_spinner_item);
        type_adapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
        type_spinner.setAdapter(type_adapter);

I want to setup from_spinner, and to_spinner from the selection of
type_spinner, so I call my setSpinner function from the onItemSelected
event of type_spinner

type_spinner.setOnItemSelectedListener(new
AdapterView.OnItemSelectedListener(){
                        @Override
                        public void onItemSelected(AdapterView<?> adapter, View 
view,
                                        int position, long arg3) {

                                clearScreen();
                                setSpinner(position);
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> arg0) {
                                type_spinner.setSelection(LIQUID_TYPE);

                        }
         });

 private void setSpinner(int type){
        switch(type){
                case TYPE1:
                         from_adapter = ArrayAdapter.createFromResource(this,
R.array.type1,
 
android.R.layout.simple_spinner_item);
                         to_adapter = ArrayAdapter.createFromResource(this, 
R.array.type1,
 
android.R.layout.simple_spinner_item);
                         break;
                case TYPE2:
                        from_adapter = ArrayAdapter.createFromResource
(this, R.array.type2,
 
android.R.layout.simple_spinner_item);
                         to_adapter = ArrayAdapter.createFromResource(this, 
R.array.type2,
 
android.R.layout.simple_spinner_item);
                         break;

         }
           from_adapter.setDropDownViewResource(
 
android.R.layout.simple_spinner_dropdown_item);
            to_adapter.setDropDownViewResource(
 
android.R.layout.simple_spinner_dropdown_item);

            from_spinner.setAdapter(from_adapter);
            to_spinner.setAdapter(to_adapter);
            from_spinner.setSelection(2); // For testing - Array has >
10 items
            to_spinner.setSelection(3); //For testing - Array has > 10
items

Please let me know how to fix this. Thanks for your help.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. (solved) WTB: Screen protector Spica, lokasi jakarta/serpong, dan bisa pasangin sekalian

Thanks all,

{*filter*}tara di closed wtb nya. Td sambil menunggu japrian saya iseng2 browsing
youtube dan ketemu cara bersihin bagian glue screen protector, yaitu dg
menggunakan tape/solasi yg bening. Ternyata memang ampuh. Thanks atas info
dr rekan2 sekalian.

Best Regards,
David Haryanto
*sent from white spica




Ga usah dicuci bisa boss, pake selotip aja ditempel2 ke bagian yang kotor,
nanti kotorannya lengket di selotipny


Sent from BlackBerry on 3


-----Original Message-----
From: David Haryanto <david.haryan...@gmail.com>
Date: Fri, 30 Apr 2010 ...

Friends,

Sorry mau WTB lagi. Soalnya barusan terima kiriman paket dari Bandung,
ternyata saya masan...

-- 
"Indonesian Android Community [id-android]" 

Join:  http://www.***.com/ 
Moderator: id.andr...@gmail.com
ID Android Developer:  http://www.***.com/ 
ID Android Surabaya:  http://www.***.com/ 
ID Android on FB:  http://www.***.com/ 

2. Can anyone with a Moto Droid run a quick test on my app please?

Hi,
My app is working fine on G1, N1, Hero etc but crashes on Droid. If
anyone can quickly run a test for me on a Motorola Droid and email me
the logcat output it would be very helpful. Please email me if you can
spare the time and I will send a link to download the apk.

-- 

3. Drawing of location accuracy in Google Maps app

4. droidfanz.com -- what does it take to get them taken down?

5. Apple buys Siri

6. (ASK) Problem download dr market setelah root dan app2sd

7. Pusat android