我做了一个收音机播放器,但搜索栏没有调高或调低音量,我找不到为什么会这样。
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
}
});