views:

38

answers:

3

I finally got my image button to work within an ImageView, and after I press it, it works, but imnmediately after, it stops running and I get the error message to close it. I added the onClick and focused it in the XML so that it will work within an imageview, but that's all I got. The button in the /drawable folder is the imagebutton selector code: http://developer.android.com/reference/android/widget/ImageButton.html

 <ImageView
 android:onClick="true"
 android:src="@drawable/button"
 android:focusable="true"
 android:layout_height="fill_parent"    
 android:layout_width="fill_parent"
 android:scaleType="fitStart"

I have a suspicion that I'm forgetting something....

A: 

I think it's with the android:onClick bit. I have never set this in XML (like you have); I'm not sure you can even do that.

What you want is an onClickListener in the Activity which uses this XML. Check this here

Espiandev
+2  A: 

Yes the first user is right. The mistake is with the android:onClick event. It is not a Boolean value. It is used to specify the name of your method that should be fired when a user clicks on the button. Check this sample here scroll down to the bottom and check how they have implemented this property.

http://android-developers.blogspot.com/2009/10/ui-framework-changes-in-android-16.html

Rahul
A: 

paste in some java code. maybe we could be of some help then.

Umesh