How do make an image clickable in android?
I don’t want to use an imageButton as it puts the image over a button.
i tried using following codes, but on clicking nothing happens..
in xml:
<ImageView
android:id="@+id/arrow1"
android:src="@drawable/arrow"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_x="12dp"
android:layout_y="90dp"
android:clickable="true"
android:onClick="onClick">
</ImageView>
in .java:
final ImageView diskView4 = (ImageView) findViewById(R.id.arrow1);
diskView4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
//my codes
}
});
no need to add extra attribute
This will do and your code seems allright. Trace your click by