【问题标题】:onTouchListener is not working in 4.0 above version of android but it is working in belowonTouchListener 在 4.0 以上版本的 android 中不起作用,但在以下版本中起作用
【发布时间】:2013-02-06 09:17:10
【问题描述】:

您好,我已经在我的服务类中实现了 ontouchlistener,并尝试获取在 android 2.3 上运行良好但不适用于更高版本的触摸事件。我正在努力解决这个问题,但即使在阅读了 stackoverflow 中的大量文档后,我也没有得到任何解决方案,这是代码..请帮我解决这个问题

在 onCreate 方法中我定义了图像按钮

    ImageButton imageButton=new ImageButton(this);
imageButton.setBackgroundColor(Color.TRANSPARENT);
imageButton.setOnTouchListener(this);

    @Override public boolean onTouch(View arg0, MotionEvent arg1) {
Toast.makeText(getApplicationContext(), "Double touched "+DoubleTouch, 1000).show();
return false;
}

【问题讨论】:

  • 没有安卓2.6版
  • 安卓2.6没有正式版
  • 好的,谢谢,请建议解决上述问题

标签: android android-4.0-ice-cream-sandwich android-4.2-jelly-bean ontouchlistener


【解决方案1】:

你想使用代码imageButton.setOnTouchListener(youActivityname.this);

【讨论】:

  • 嗨@saravanan 谢谢你的好意,我也实现了这个但它不起作用,实际上我已经在服务类中实现了 onTouchListener
猜你喜欢
  • 2019-09-25
  • 2019-09-19
  • 1970-01-01
  • 2023-04-06
  • 1970-01-01
  • 2014-07-30
  • 1970-01-01
  • 2018-06-15
  • 1970-01-01
相关资源
最近更新 更多