2017-02-20 102 views

回答

0

試試這個:

final Button bOne = (Button) findViewById(R.id.button_one); 
final Button bTwo = (Button) findViewById(R.id.button_two); 
bOne.setOnTouchListener(new View.OnTouchListener() { 
    @Override 
    public boolean onTouch(View view, MotionEvent motionEvent) { 
     view.setPressed(true); 
     bTwo.setPressed(false); 
     return true; 
    } 
}); 
bTwo.setOnTouchListener(new View.OnTouchListener() { 
    @Override 
    public boolean onTouch(View view, MotionEvent motionEvent) { 
     view.setPressed(true); 
     bOne.setPressed(false); 
     return true; 
    } 
}); 
相關問題