Android 按钮的长按事件和抬起事件的监听

iv_buttom_home = (ImageView) findViewById(R.id.iv_buttom_home);
		iv_buttom_home
				.setOnLongClickListener((OnLongClickListener) new ButtomLongClick());
		iv_buttom_home
				.setOnTouchListener((OnTouchListener) new ButtomLongClick());
 
 
自定义的监听类,继承了长按和触摸事件
class ButtomLongClick implements OnLongClickListener, OnTouchListener {
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if (v.getId() == R.id.iv_buttom_home && misBottomhide) {
				if (event.getAction() == MotionEvent.ACTION_UP) {
					Animation anim = AnimationUtils.loadAnimation(
							getApplicationContext(), R.anim.push_top_in);
					anim.setAnimationListener(BottomActivity.this);
					ly_bottom_bar.startAnimation(anim);
					misBottomhide = false;
				}
			}
			return false;
		}




你可能感兴趣的:(Android 按钮的长按事件和抬起事件的监听)