Android Seekbar没有响应
我做了一个无线电播放器,但seekbar没有调高或调低音量,我不知道为什么会发生这种情况Android Seekbar没有响应,android,Android,我做了一个无线电播放器,但seekbar没有调高或调低音量,我不知道为什么会发生这种情况 final SeekBar volume=(SeekBar)findViewById(R.id.bar); audMan = (AudioManager)getSystemService(Context.AUDIO_SERVICE); int maxVolume = audMan.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int curVolume = a
final SeekBar volume=(SeekBar)findViewById(R.id.bar);
audMan = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
int maxVolume = audMan.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int curVolume = audMan.getStreamVolume(AudioManager.STREAM_MUSIC);
mplayer = new MediaPlayer();
mplayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
volume.setMax(maxVolume);
volume.setProgress(curVolume);
song_title=(TextView)findViewById(R.id.txt);
seekBarValue=(TextView)findViewById(R.id.textView1);
Value=(TextView)findViewById(R.id.seekbarvalue);
song_title.setTextColor(Color.CYAN);
seekBarValue.setTextColor(Color.CYAN);
Value.setTextColor(Color.CYAN);
volume.setProgress(0);
volume.incrementProgressBy(5);
volume.setMax(100);
volume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
public void onStopTrackingTouch(SeekBar bar)
{
int value = bar.getProgress(); // the value of the seekBar progress
}
public void onStartTrackingTouch(SeekBar bar)
{
}
public void onProgressChanged(SeekBar bar,
int paramInt, boolean paramBoolean)
{
seekBarValue.setText("" + paramInt + "%"); // here in textView the percent will be shown
}
});
你必须在某个时候打电话给
public void onProgressChanged(SeekBar bar,
int paramInt, boolean paramBoolean)
{
seekBarValue.setText("" + paramInt + "%"); // here in textView the percent will be shown
AudioManager audioManager = (AudioManager)Context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,paramInt,flags);
}
标志只是要使用的标志。例如,AudioManager.FLAG_SHOW_UI可用于显示带有音量的祝酒词。如果不需要标志,可以传递0。卫星AudioManager AudioManager是否出现任何错误。。。是否有错误提示类型不匹配:无法从对象转换为AudioManager,且标志为varieble?