// sự kiện chạm cho button
public static void SuKienChamButton(Button btn,final Integer beginResource ,final Integer Resource) { btn.setOnTouchListener(new View.OnTouchListener() { @Override
public boolean onTouch(View v, MotionEvent event) { //imvBackActionBar.setBackgroundColor(Color.parseColor("#FF6E9BF5"));
switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { Button bt = (Button) v; //overlay is black with transparency of 0x77 (119)
bt.setBackgroundResource(beginResource); bt.invalidate(); break; } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { Button bt = (Button) v; //clear the overlay
bt.setBackgroundResource(Resource); bt.invalidate(); break; } } return false; } }); }
No comments:
Post a Comment