こんにちは、以下のコードでは、オン/オフのテキスト名が 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" />
Switch.java:
simpleSwitch1.setOnToggledListener(new OnToggledListener() {
@Override
public void onSwitched(LabeledSwitch labeledSwitch, boolean isChecked) {
if (isChecked) {
Log.i(TAG, "Switch-checked");
dValue1.setText("9");
}
}
});