嗨,在下面的代码中,我有一个自定义切换开关,开/关的文本名称是 DAY/Night。我只是显示第 6 天到第 18 天的一些默认值。如果我选择天想要显示 6 到 18 个数字。如果我选择夜晚意味着我想显示 19 到 5。任何人都可以帮助我
切换开关.xml:
<com.github.angads25.toggle.LabeledSwitch
android:id="@+id/switch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="7dp"
android:textSize="14sp"
app:colorBorder="@color/colorAccent"
app:colorOn="#2a9ed1"
app:on="true"
app:textOff="NIGHT"
app:textOn="DAY" />
开关.java:
simpleSwitch1.setOnToggledListener(new OnToggledListener() {
@Override
public void onSwitched(LabeledSwitch labeledSwitch, boolean isChecked) {
if (isChecked) {
Log.i(TAG, "Switch-checked");
dValue1.setText("9");
}
}
});