开发者

How to define function in a string in Android?

I have an event handler that I want to be connected to a button through xml.

Basically, I want to define it as a stri开发者_运维百科ng in my xml file, then use the property inspector to select the name of the handler for my button (the "on Click" property).

How do I define a call to the function in the string?


It's "Easier click listeners" section here http://android-developers.blogspot.com/2009/10/ui-framework-changes-in-android-16.html


You can't can attach a function from XML.
What you do is create a layout, inflate it from Java code, find the button by id and attach a function that will be called on click.
This is covered in introductory tutorials.

EDIT:
As pointed out by Romain Guy, http://developer.android.com/intl/de/reference/android/view/View.html#attr_android:onClick
(but I'd say it's crazy anyways :))

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜