Android 如何在钢琴按键中使用选择器

Android 如何在钢琴按键中使用选择器,android,Android,当我点击图像视图时,他们不能执行任何操作,他们不能更改图像视图后面的可绘制图像。如何在代码中使用选择器 rel1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { int action = event.getAction(); if (action != MotionEvent.AC

当我点击图像视图时,他们不能执行任何操作,他们不能更改图像视图后面的可绘制图像。如何在代码中使用选择器

rel1.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View arg0, MotionEvent event) {
        int action = event.getAction();
        if (action != MotionEvent.ACTION_DOWN 
            && action != MotionEvent.ACTION_MOVE 
            && action != MotionEvent.ACTION_UP) return false;

        Rect hitRect = new Rect();
        ImageView button;

        for(int i = 0; i < myButton1.size(); i++) {
            button = myButton1.get(i);

            button.getHitRect(hitRect);
            if (hitRect.contains((int)event.getX(), (int)event.getY())) {
                //myButton1.get(i).setImageDrawable(getResources().getDrawable(R.drawable.white_up));   

                SoundManager.playShoot(i);
            }
        }
        return true;
    }
});
rel1.setOnTouchListener(新的OnTouchListener(){
@凌驾
公共布尔onTouch(视图arg0,运动事件){
int action=event.getAction();
if(action!=MotionEvent.action\u DOWN
&&动作!=MotionEvent.action\u移动
&&action!=MotionEvent.action\u UP)返回false;
Rect hitRect=new Rect();
图像查看按钮;
对于(int i=0;i