我想要检测用户在Android应用程序的任何位置查看视图的任何位置。如何检测用户在Android中查看视图的时间
我的代码如下所示:
linearLayout = (LinearLayout) findViewById(R.id.linearLayout); // main layout
// ...
linearLayout.setOnTouchListener(this);
// ...
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(this, "Touch!", 1000);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Toast.makeText(this, "Down!", 1000);
return true;
}
return false;
}
...但是当我点击的看法,我不明白吐司!
触摸事件是否在模拟器中工作 - 或者我的代码中有错误吗?
我一直在寻找相同的解决方案。感谢Biswajit – 2016-05-23 17:58:33