how to change state of a Switch programmatically andoir dstudio
Switch a; // define your switch
a.setOnClickListener(
     new View.OnClickListener() {
         @Override
         public void onClick(View view) {
               b.setChecked(!b.isChecked);
         }
      });
