In Android SDK overriden method toString use actionToString method as a have public static modificators. If you open source code you must see :
@Override
public String toString() {
StringBuilder msg = new StringBuilder();
msg.append("MotionEvent { action=").append(actionToString(getAction()));
final int pointerCount = getPointerCount();
for (int i = 0; i < pointerCount; i++) {
msg.append(", id[").append(i).append("]=").append(getPointerId(i));
msg.append(", x[").append(i).append("]=").append(getX(i));
msg.append(", y[").append(i).append("]=").append(getY(i));
msg.append(", toolType[").append(i).append("]=").append(
toolTypeToString(getToolType(i)));
}
msg.append(", buttonState=").append(MotionEvent.buttonStateToString(getButtonState()));
msg.append(", metaState=").append(KeyEvent.metaStateToString(getMetaState()));
msg.append(", flags=0x").append(Integer.toHexString(getFlags()));
msg.append(", edgeFlags=0x").append(Integer.toHexString(getEdgeFlags()));
msg.append(", pointerCount=").append(pointerCount);
msg.append(", historySize=").append(getHistorySize());
msg.append(", eventTime=").append(getEventTime());
msg.append(", downTime=").append(getDownTime());
msg.append(", deviceId=").append(getDeviceId());
msg.append(", source=0x").append(Integer.toHexString(getSource()));
msg.append(" }");
return msg.toString();
}
And if you open actionToString method in the SAME class:
public static String actionToString(int action) {
switch (action) {
case ACTION_DOWN:
return "ACTION_DOWN";
case ACTION_UP:
return "ACTION_UP";
case ACTION_CANCEL:
return "ACTION_CANCEL";
case ACTION_OUTSIDE:
return "ACTION_OUTSIDE";
case ACTION_MOVE:
return "ACTION_MOVE";
case ACTION_HOVER_MOVE:
return "ACTION_HOVER_MOVE";
case ACTION_SCROLL:
return "ACTION_SCROLL";
case ACTION_HOVER_ENTER:
return "ACTION_HOVER_ENTER";
case ACTION_HOVER_EXIT:
return "ACTION_HOVER_EXIT";
}
int index = (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT;
switch (action & ACTION_MASK) {
case ACTION_POINTER_DOWN:
return "ACTION_POINTER_DOWN(" + index + ")";
case ACTION_POINTER_UP:
return "ACTION_POINTER_UP(" + index + ")";
default:
return Integer.toString(action);
}
}
But, when i try to use this method
MotionEvent.actionToString(event.getAction);
IDE tell me about error.
Cannot resolve method actionToString(int);
Why i getting this error?
Link to the class methods :