控件
performMultiPointerGesture
public boolean performMultiPointerGesture(PointerCoords[] ...touches) {
try {
if (API_18) {
// The compile-time SDK expects the wrong arguments, but the runtime
// version in the emulator is correct. So we cannot do:
// `return el.performMultiPointerGesture(touches);`
// Instead we need to use Reflection to do it all at runtime.
Method method = this.el.getClass().getMethod("performMultiPointerGesture", PointerCoords[][].class);
Boolean rt = (Boolean)method.invoke(this.el, (Object)touches);
return rt;
} else {
Logger.error("Device does not support API < 18!");
return false;
}
} catch (final Exception e) {
Logger.error("Exception: " + e + " (" + e.getMessage() + ")");
return false;
}
}
UiObject中有直接可以調用的performMultiPointerGesture方法,為什麼還要用反射呢。上面的方法裡的注釋是這樣解釋的:編譯的時候sdk會認為參數是錯誤的,但是運作時卻認為是正确的,是以隻有在運作時調用才能保證正确性。反射調用的就是運作時的環境,是以它使用了反射調用了performMultiPointerGesture。
點組