Android. Gethistorysize And Gethistoricalx/y
I have overridden the onTouchEvent() method in my View class, and tried to handle an EventMotion.ACTION_MOVE. I use the following code : if (event_.getAction() == MotionEvent.ACTIO
Solution 1:
I've just come across the same issue. It would appear that after 2.3.x getHistoricalX() and getHistoricalY() now throw an ArrayIndexOutOfBounds when passed a negative figure. Previously they just returned the first entry in the history. This would happen where historySize is 0, from a very short press,
Thus, although you do not want to discuss code safety, the answer is a check on the historySize as follows. If historySize==0, although a Move event, it hasn't actually moved so presumably you don't want to do anything.
if (event_.getAction() == MotionEvent.ACTION_MOVE) {
historySize = event_.getHistorySize();
if(historySize>0)
endX = event_.getHistoricalX(historySize-1);
}
Post a Comment for "Android. Gethistorysize And Gethistoricalx/y"