Android 如何使用ToggleButton更改所有声音的音调?

Android 如何使用ToggleButton更改所有声音的音调?,android,touch,togglebutton,soundpool,Android,Touch,Togglebutton,Soundpool,我有一个扩展按钮的类: package dubpad.brendan; import android.content.Context; import android.media.AudioManager; import android.media.SoundPool; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.Button; public class

我有一个扩展按钮的类:

package dubpad.brendan;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.util.AttributeSet;

import android.view.MotionEvent;
import android.widget.Button;



public class TestButton extends Button {.

   SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
   int soundID = soundPool.load(getContext(), R.raw.bass, 0);
   Sound sound = new Sound(soundPool, soundID);
   int streamid;

public TestButton(final Context context, final AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
}

@Override
public boolean onTouchEvent(final MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN||event.getAction()==MotionEvent.ACTION_POINTER_DOWN||event.getAction()==MotionEvent.ACTION_POINTER_1_DOWN||event.getAction()==MotionEvent.ACTION_POINTER_2_DOWN||event.getAction()==MotionEvent.ACTION_POINTER_3_DOWN) {
            streamid = sound.play(1);           
   }

if (event.getAction()==MotionEvent.ACTION_UP||event.getAction()==MotionEvent.ACTION_POINTER_UP||event.getAction()==MotionEvent.ACTION_POINTER_1_UP||event.getAction()==MotionEvent.ACTION_POINTER_2_UP||event.getAction()==MotionEvent.ACTION_POINTER_3_UP){
sound.stop(streamid);
     }  
    return super.onTouchEvent(event);
}

 }
我想实现一个ToggleButton并检查它是否被选中,如果是,我想增加音高,如果不是,我想减小音高。在ACTION_上声明ToggleButton对象并检查它是否无效。我有许多其他的类来扩展按钮,我如何捕捉streamID并改变音高