irfan
irfan

Reputation: 869

disable touch input in android programmatically

I want to disable touch input in an activity during certain conditions. Is there any way to accomplish disable touch?

Upvotes: 4

Views: 12094

Answers (3)

Victor
Victor

Reputation: 183

To disable touch events on an activity:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

To re-enable touch events:

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

Upvotes: 2

Ali Al Fayed
Ali Al Fayed

Reputation: 524

    this.setFinishOnTouchOutside(false)

Upvotes: -1

Srikanth
Srikanth

Reputation: 2114

Get the view that you want to disable the touch inputs on and setOnTouchListener(null)

Upvotes: 1

Related Questions