I have in my app an an settings activity with many switches. I tried to avoid writing 50 setOnCheckedChangeListener I tried to set a onClick event in the layout file:
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/switchVibra"
android:layout_weight="0.1"
android:onClick="switchChange" />
The methode:
public void switchChange(View v){
switch (v.getId()){
case R.id.switchVibra:
// Do something
break;
}
}
But this method doesn't register a change when you wipe the switch. Is there a other option to avoid writing a listener for every switch?