Reputation: 3221
I've got many of such ImageViews
<ImageView
android:src="@drawable/img23"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:onClick="myClickHandler">
image view successfully calls the method "myClickHandler(View v)"
in that method
public void myClickHandler(View v) {
Log.i("V Class",""+v.getClass().toString()+" "+
v.getHeight()+" X "+v.getWidth()+" "+v.getId());
}
Although the log prints
09-09 12:48:10.401: INFO/V Class(17399): class android.widget.ImageView 59 X 59 -1
here i got class name(ImageView), height X width, but somehow i am not able to get Id of the image clicked....
Upvotes: 0
Views: 81
Reputation: 13327
try
<ImageView
android:id="@+id/img234"
android:src="@drawable/img23"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:onClick="myClickHandler">
Upvotes: 0
Reputation: 13960
Obviously, you haven't given an id to your View.
<ImageView android:id="@+id/my_view_id"
android:src="@drawable/img23"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:onClick="myClickHandler">
Upvotes: 0
Reputation: 57573
In your XML android:id
is not defined: could this lead to this behaviour?
Upvotes: 1