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. How to use jdb? "Deferring breakpoint ... It will be set after the class is loaded."

I prefer to not use Eclipse, but I do like its ability to set
breakpoints, query values, and step through programs. I believe that
this is possible using a combination of ddms and jdb, but I have not
been able to set a breakpoint.

Here's what I do:

1. I start the emulator:
   emulator -avd my.avd &

2. I install my app:
   adb -e install -r bin/HelloWorldActivity-debug.apk

3. In the emulator, I go to Dev Tools/Development Settings and set
"Wait for De{*filter*}". I choose the app in that must wait.

4. I start up ddms:
    ddms &

5. I start the app on the emulator. It obediently says it's waiting
for the de{*filter*} to attach.

6. ddms shows the app with port 8700 active.  So I start up jdb using
port 8700.

7. The app immediately starts before I can set any breakpoints. Eg. if
I try to set a breakpoint in the main Activity, jdb says:

Deferring breakpoint HelloWorldActivity.java:285.
It will be set after the class is loaded.

I've tried putting my breakpoint commands in .jdbrc, but those are too
late there too; I get the same message.

I suspect that Eclipse must use the same set of tools, but in the
right sequence, so it must be possible. But what is that right
sequence?

Thanks !

Jim

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

2. ATITC graphics format

I found a video on "Writing Real Time Games for Android" (http://
www.scribd.com/doc/16917369/Writing-Real-Time-Games-for-Android) which
mentioned that the G1 supports ATITC format. I assume this ATI's
Texture Compression.

I've searched for more details but I can't find much information on
this format. Specifically I'd like to know where I can find an app/
plugin to convert to this format (Can "The Compressonator" do it?) and
how to load it. texImage2D only takes a Bitmap, which it looks like it
only supports JPEG, GIF, PNG, and BMP.

Thanks in advance.

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

3. Telling another activity which item was clicked.

4. How to simulate a TrackBall Event in emulator?

5. Instrumentation on the virtual keyboard.

6. Problem :can't read a file, can't comunicate with a server

7. Failed to find provider info for com.google.settings