开发者

Android - Button Question

开发者 https://www.devze.com 2023-01-13 19:59 出处:网络
I finally got m开发者_JAVA百科y 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 finally got m开发者_JAVA百科y 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....


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消