0

我想打开一个开关然后再关闭。我试过这样:

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    swtch.setChecked(true);
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    swtch.setChecked(false);
}

开关将变为蓝色,但不会向右移动。200 毫秒后,它会再次变灰。它也一直说OFF。如何使开关切换到 ON 并再次切换回 OFF?

4

0 回答 0