以 OnTouchListener
接口为例:
package android.view;
public class View implements Drawable.Callback, KeyEvent.Callback, AccessibilityEventSource
{
public interface OnTouchListener
{
boolean onTouch(View var1, MotionEvent var2);
}
}
在Java中使用时:
mView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event)
{
// do somthing
return true;
}
});
在Auto.js中使用:
importClass( android.view.View );
// 创建一个新的悬浮窗口对象
let fw = floaty.window(
<vertical>
<text
id="myText"
padding="5"
bg="#D6D7D7"
textStyle="bold"
textSize="30px"
text="Hello World" />
</vertical>
);
let listener = new View.OnTouchListener()
{
// public interface OnTouchListener {
// boolean onTouch(View var1, MotionEvent var2);
// }
onTouch: ( view, motionEvent ) => {
console.log( motionEvent.getAction() );
return true;
}
}
console.log( listener );
fw.myText.setOnTouchListener( listener );
setInterval( () => {
return;
}, 4000 );