Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何设置默认卷?_Android_Checkbox_Volume - Fatal编程技术网

Android 如何设置默认卷?

Android 如何设置默认卷?,android,checkbox,volume,Android,Checkbox,Volume,我的复选框必须使musicbackroud静音。如何更改回默认卷 if (checkBox.isChecked()) { musicbackground.setVolume(0, 0);} else { ??? } MediaPlayer的初始音量为1.0 因此,您可以使用两个额外的变量跟踪当前和以前的卷: float currentVolume =

我的复选框必须使musicbackroud静音。如何更改回默认卷

        if (checkBox.isChecked()) {
            musicbackground.setVolume(0, 0);}
            else
            {
                ???
            }
MediaPlayer的初始音量为1.0

因此,您可以使用两个额外的变量跟踪当前和以前的卷:

float currentVolume = 1.0f;
float previousVolume = 1.0f;

...

// Changing volume to 0
previousVolume = currentVolume;
currentVolume = 0;
musicbackground.setVolume(currentVolume, currentVolume);

...

// Restoring the old volume
temp = previousVolume;
previousVolume = currentVolume;
currentVolume = temp;
musicbackground.setVolume(currentVolume, currentVolume);

谢谢,它适用于musicbackground.setVolume1,1。我不知道;P