Add method for updating "checked" state of compound button in bottom sheet menu item

This commit is contained in:
Alexander Sytnyk 2018-03-14 17:32:45 +02:00
parent 8e00c3f91a
commit 5744a981d7

View file

@ -17,6 +17,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
private boolean checked;
private ColorStateList buttonTintList;
private CompoundButton compoundButton;
public BottomSheetItemWithCompoundButton(View customView,
@LayoutRes int layoutId,
Object tag,
@ -45,10 +47,15 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
this.buttonTintList = buttonTintList;
}
public void setChecked(boolean checked) {
this.checked = checked;
compoundButton.setChecked(checked);
}
@Override
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
super.inflate(app, container, nightMode);
CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
compoundButton.setChecked(checked);
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
}