i want to apply an onClickListener event to an imageView, how do I accomplish this? Can anyone provide me with some source code examples
i want to apply an onClickListener event to an imageView, how do I accomplish this? Can anyone provide me with some source code examples
In xml:
<ImageView
android:clickable="true"
android:onClick="imageClick"
android:src="@drawable/myImage">
</ImageView>
In code
public class Test extends Activity {
........
........
public void imageClick(View view) {
//Implement image click function
}
Lambda Expression JAVA
ImageView img = findViewById(R.id.imageview1);
img.setOnClickListener(v ->
{
//Your Handler Code
});