The setClickable method is a method of the android.view.View class, and is used to set whether the view can be clicked or not. Setting a view to clickable means that it can receive click events, and can be used to perform an action when the view is clicked.
Example 1:
In this example, we have a button view named myButton, and we want it to be clickable. We can use setClickable method in the following way:
Button myButton = findViewById(R.id.my_button); myButton.setClickable(true); //set the button as clickable
This code sets the myButton view to be clickable, and it can now receive click events.
Example 2:
In this example, we have an ImageView named myImage, and we do not want it to be clickable. We can use setClickable method in the following way:
ImageView myImage = findViewById(R.id.my_image); myImage.setClickable(false); //set the image as not clickable
This code sets the myImage view to be not clickable, and it will not receive click events.
Package Library: android.view.
Java View.setClickable - 30 examples found. These are the top rated real world Java examples of android.view.View.setClickable extracted from open source projects. You can rate examples to help us improve the quality of examples.