Q: can't programmatically change toggle button I can't seem to programmaticaly set a ToggleButton to off (false)- I have done much searching and trying things I have found, but just cannot make it work. The relevant code it here-
  while (toggleButton4_.isChecked()){
seekBar_.setProgress(0);
toggleButton2_.setSelected(false);  
pwmOutput1_.setDutyCycle(0);        
pwmOutput2_.setPulseWidth(500);     
  }

The seekbar sets to zero ok, the two pwm outputs go to zero and 500 respectively, but the toggleButton and it's pin do not change.
I would be glad of any help, the simpler the better as I am very much a beginner with java.
Thanks, Ken.
Update- I tried toggle() also, same result, so you are correct, there must be a mistake elsewhere. Here is the full Main Activity from my app-
    package ioio.examples.hello;


import ioio.lib.api.DigitalInput;
import ioio.lib.api.DigitalOutput;
import ioio.lib.api.DigitalOutput.Spec.Mode;
import ioio.lib.api.PwmOutput;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.util.BaseIOIOLooper;
import ioio.lib.util.IOIOLooper;
import ioio.lib.util.android.IOIOActivity;
import kens.tws.R;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.ToggleButton;



public class MainActivity extends IOIOActivity {
    private Button button1_;
        private Button button2_;
    private SeekBar seekBar_;
    private ToggleButton toggleButton1_;
    private ToggleButton toggleButton2_;
    private ToggleButton toggleButton3_;
    private ToggleButton toggleButton4_;

        /**
     * Called when the activity is first created. Here we normally initialize
     * our GUI.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);


        seekBar_ = (SeekBar) findViewById(R.id.seekBar1);
        toggleButton1_ = (ToggleButton) findViewById(R.id.frButton);
        toggleButton2_ = (ToggleButton) findViewById(R.id.fieldButton);
        toggleButton3_ = (ToggleButton) findViewById(R.id.lightsButton);
        toggleButton4_ = (ToggleButton) findViewById(R.id.emBrakeButton);
        button1_ = (Button) findViewById(R.id.engineStartButton);
        button2_ = (Button) findViewById(R.id.hornButton);

    }

    /**
     * This is the thread on which all the IOIO activity happens. It will be run
     * every time the application is resumed and aborted when it is paused. The
     * method setup() will be called right after a connection with the IOIO has
     * been established (which might happen several times!). Then, loop() will
     * be called repetitively until the IOIO gets disconnected.
     */
    class Looper extends BaseIOIOLooper {

        private DigitalOutput engineStartButton_;
        private DigitalOutput hornButton_;
        private DigitalOutput fieldButton_;
        private DigitalOutput frButton_;
        private DigitalOutput lightsButton_;
        private DigitalOutput emBrakeButton_;
        private PwmOutput pwmOutput1_;
        private PwmOutput pwmOutput2_;
        private final int brakeOnPin = 18 ;
        private DigitalInput brakeOn ;

        /**
         * Called every time a connection with IOIO has been established.
         * Typically used to open pins.
         * 
         * @throws ConnectionLostException
         *             When IOIO connection is lost.
         * 
         * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
         */
        @Override
        protected void setup() throws ConnectionLostException {
            engineStartButton_ = ioio_.openDigitalOutput(3, false);
            hornButton_ = ioio_.openDigitalOutput(6, false);
            frButton_ = ioio_.openDigitalOutput(14, false);
            fieldButton_ = ioio_.openDigitalOutput(11, false);
            lightsButton_ = ioio_.openDigitalOutput(13, false);
            emBrakeButton_ = ioio_.openDigitalOutput(16, false);
            pwmOutput1_ = ioio_.openPwmOutput(5, 100);  //alternator field control
            pwmOutput2_ = ioio_.openPwmOutput(new DigitalOutput.Spec(10, Mode.OPEN_DRAIN), 100); //throttle servo
            brakeOn = ioio_.openDigitalInput(brakeOnPin, DigitalInput.Spec.Mode.PULL_UP);
            }


        /**
         * Called repetitively while the IOIO is connected.
         * @throws ConnectionLostException
         *             When IOIO connection is lost.
         * 
         * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
         */

    @Override
    public void loop() throws ConnectionLostException {
        pwmOutput1_.setPulseWidth(seekBar_.getProgress() * 100);  //alternator field
        pwmOutput2_.setPulseWidth(500 + seekBar_.getProgress() * 14);  //engine throttle
        engineStartButton_.write(button1_.isPressed());
        hornButton_.write(button2_.isPressed());
        frButton_.write(!toggleButton1_.isChecked());
        fieldButton_.write(toggleButton2_.isChecked());
        lightsButton_.write(toggleButton3_.isChecked());
        //  emBrakeButton_.write(toggleButton4_.isChecked());

        while (toggleButton4_.isChecked()){
        // Emergency brake is on, so turn field relay off, zero seekbar, set field switch
        //  to off, and set both pwm's to zero. 
            seekBar_.setProgress(0);
            fieldButton_.write(false);
            toggleButton2_.setChecked(false);  //alternator field switch
            pwmOutput1_.setDutyCycle(0);        //alternator field winding pwm
            pwmOutput2_.setPulseWidth(500);     //engine throttle servo 
        }  

        try {
                if (!brakeOn.read()) {
                   // brake pin is pulled low, so zero pwm and seekBar
                    seekBar_.setProgress(0);
                    pwmOutput1_.setDutyCycle(0);
                    pwmOutput2_.setPulseWidth(500);
                }

            } catch (InterruptedException e) {
                // do nothing
            }
          try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
        }
    }


    } // End class Looper
    /**
     * A method to create our IOIO thread.
     * 
     * @see ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
     */
        @Override
        protected IOIOLooper createIOIOLooper() {

            return new Looper();
        }


    } // End class MainActivity

Also, here is the relevant button's xml-
  <ToggleButton
    android:id="@+id/fieldButton"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_column="0"
    android:layout_gravity="center_horizontal|top"
    android:layout_row="0"
    android:background="@drawable/field_button_toggle"
    android:checked="false"
    android:text="@string/field"
    android:textOff="@string/field_off"
    android:textOn="@string/field_on" />

I also use a colors.xml
    <?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#ff0000</color>
    <color name="green">#00ff00</color>
    <color name="blue">#0000ff</color>
    <color name="orange">#ff8800</color>
    <color name="white">#ffffff</color>
</resources>

and another xml for the field buttons drawable-
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false" android:drawable="@color/green"  />
    <item android:state_checked="true" android:drawable="@color/red"  />
</selector>

Thanks, I really appreciate what you are doing for me, 
Ken.

A: You're looking for:
toggleButton2_.setChecked(false);


A: Use this instead:
if (toggleButton4_.isChecked()){
  seekBar_.setProgress(0);
  toggleButton2_.setChecked(false);  
  pwmOutput1_.setDutyCycle(0);        
  pwmOutput2_.setPulseWidth(500);     
  }

Cheers :)

A: What you have to do is use: (1)
toggleButton2_.setChecked(false);

So it would look like this:
while (toggleButton4_.isChecked()){
    seekBar_.setProgress(0);
    toggleButton2_.setChecked(false);  
    pwmOutput1_.setDutyCycle(0);         
    pwmOutput2_.setPulseWidth(500);     
}

But I don't understand your loop. It is infinite. Instead of using while use if. So finally it will become: (2)
if (toggleButton4_.isChecked()){
    seekBar_.setProgress(0);
    toggleButton2_.setChecked(false);  
    pwmOutput1_.setDutyCycle(0);         
    pwmOutput2_.setPulseWidth(500);     
}

But yes this depends on what you are doing. The 2 things should do the trick.
