Disclaimer: I’ve never dealt w/ Android coding. This is purely blind advice!
- In Java everything must be inside a class or interface.
- Processing hides that basic truth from us when our code is inside a “.pde” file.
- But if we check the “.java” file which got transpiled out of our “.pde” files we’ll realize everything ends up wrapped inside a PApplet subclass after all.
- When we need to define a callback function in Java, that also ends up belonging to some class or interface.
- So even callbacks gotta belong to some datatype and all of its inherited datatypes.
- And consequently we need to pass an instance of a callback’s class instead of the callback itself.
- Unless a callback belongs to a @FunctionalInterface; in which case we can alternatively pass a lambda expression instead.
- According to Android’s documentation, we’re advised to create a helper class w/ suggested name Dpad.
- Plus a subclass which
extends
class View w/ suggested name GameView, in which we can @Override View’s callback functions. - Basically that’s where you should define your customized onKeyDown() callback event method aKa listener.
- Unfortunately that’s where I can’t help you anymore!
- It seems like parent class View is merely a placeholder for listener callback methods.
- Instantiating a
new
View doesn’t magically activate its listeners at all. - You’d still need to pass its instance to some “unknown” Android method which will then register & start listening to the View’s callbacks within your sketch app.