I got these simple lines of code:
MainActivity:
public class MainActivity extends FragmentActivity implements ActionBar.TabListener {
(...)
public void VehicleDeleteModus(View v){
boolean on = ((ToggleButton) v).isChecked();
(...)
}
}
XML:
<Switch
android:id="@+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="VehicleDeleteModus"
android:paddingLeft="12dp"
android:text="Delete-Modus"
android:textColor="#ffffff" />
source: http://developer.android.com/guide/topics/ui/controls/togglebutton.html
The app compiles and gets installed on my Galaxy Nexus without any errors. However, I get this exception immediately after pressing the switch (on/off-slider):
android.widget.switch cannot be cast to android.widget.togglebutton
Any suggestions?