1

I want to make my android activity unclickable. I have tried Enable/disable an activity programatically but it's not working for me.

I also tried to get relative layout disable but it is not working.

Is there any other ways for making and android activity(full) unclickable?

Community
  • 1
  • 1
eswaat
  • 733
  • 1
  • 13
  • 31

3 Answers3

3

You can create a fake transparent view which takes up with whole screen and place it on top of all views.

private boolean shouldBlockTouches = false;

fakeView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return shouldBlockTouches;
        }
    });

set the shouldBlockTouches where ever you please.

Aswin Rajendiran
  • 3,399
  • 1
  • 21
  • 18
2

You could set every view as unclickable in the XML:

android:clickable="false"
bo malone
  • 178
  • 6
  • Yes, but could you provide alternative solution to make this from java code and on button click not from XML. – eswaat Jan 27 '14 at 18:50
  • Sure, try using setEnabled(false) on each button. That should make them unclickable as well. – bo malone Jan 27 '14 at 18:59
0

I think u can try by applying onClick on root layout and do nothing.tou can do this as well if u want activity unclickable then doesn't provide any beahvior will tend to do nothing.

Manmohan Badaya
  • 2,326
  • 1
  • 22
  • 35