我正在尝试stream volume
使用SeekBar
(audioMan IS 已初始化)调整 a:
sbTest = (SeekBar)findViewById(R.id.seekBar1);
sbTest.setMax(audioMan.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
sbTest.setProgress(audioMan.getStreamVolume(AudioManager.STREAM_MUSIC));
sbTest.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
audioMan.adjustStreamVolume(AudioManager.STREAM_MUSIC,
progress, AudioManager.FLAG_SHOW_UI);
}
});
IllegalArgumentException
我一触碰应用程序就会崩溃SeekBar
。LogCat 的第一行(后面是大量系统类的行号):
04-22 22:58:28.400: E/AndroidRuntime(28881): FATAL EXCEPTION: main
04-22 22:58:28.400: E/AndroidRuntime(28881): java.lang.IllegalArgumentException: Bad direction 8
我想我传递给该方法的整数参数是无效的。那么如何使用 SeekBar 调整流音量?