I have a game view which is an extension of View class. In this view I use canvas drawing objects, which the users can interact with.
This view loaded to the layout of an activity. I want to disable all user inputs to the game view, when a button is clicked in the layout.
I tried using
gameView.setEnabled(false);
gameView.setClickable(false);
But still the user can interact with the canvas objects.
FYI : Gameview class implements following interfaces as well.
public class Gameview extends View implements OnGestureListener,
OnDoubleTapListener, OnScaleGestureListener, AnimationListener
To use the Touch Lock app, launch the app and then tap Start Service. You'll notice that the app icon appears in your notification bar. Next, head to the app you want to use, and when you're ready to lock the screen, pull down the notification bar and tap Lock Touch. Your phone screen will now be disabled.
You can do this:
gameView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
It will capture all user input, and if you return true, it will stop here. If you return false it will assume that you have not handled the event and pass it on to the next listener. You can have a boolean variable that you set to true / false when you need to enable / disable your view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With