tags:

views:

19

answers:

0
Spinner spinner = (Spinner) findViewById(R.id.sensor_list);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.sensor_list, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    final Sensor_Spinner spin_listener = new Sensor_Spinner();
    spinner.setOnItemSelectedListener(spin_listener);
    Object tempObject = spinner.getSelectedItem();
    sensorSize = (double) Double.parseDouble(tempObject.toString());
    //sensorSize = spin_listener.getSelection();

This is within a tabActivity and sensorSize is declared as a class variable public static double.

My Sensor_Spinner is:

  public static double selection = 1.1;   

    public void onItemSelected(AdapterView<?> parent,
            View view, int pos, long id) {

               parent.setSelection(pos);

               selection = 1.4;
               //tab_16x9.tempy = 1.5;
           }
     public double getSelection(){

        return selection;
     }

Neither the getSelectedItem() or my custom getSelection() works for changing the value of sensorSize. I can only get it to work by creating a class variable and changing it directly from my Sensor_Spinner via onItemSelected. I'm sure this makes no sense but any help you can give would be appreciated. What are the drawbacks of using a class variable?