Monday, July 4, 2011

Re: [android-developers] question about onclick xml attribute for views

On Mon, Jul 4, 2011 at 3:05 PM, Sachin Dole <sachin.dole@gmail.com> wrote:
> On the javadoc for the android:onclick xml attribute, it says the following.
> What does the part about being able to provide a "reference to a resource"
> mean?

I think it means that you can have a string resource with the name of
the method.

> Do I have the ability to configure any class in my project to be a
> handler for onclick events or does it have to be a context (activity)?

It has to be *the* activity that inflates the layout.

> Daring to follow the javadoc as it looked did not help. I had this line:
> android:onClick="@com.gv.android:Handler:makeMeCoffee" for a method named
> com.gv.andoid.Handler#makeMeCoffee. However, the compiler complained with
> layout\student_listing.xml:11: error: Error: No resource type specified (at
> 'onClick' with value '@com.gv.android:Handler:makeMeCoffee').. Yes, I do
> have the Handler class with a makeMeCoffee method.

That is not a string resource.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in London: http://bit.ly/smand1, http://bit.ly/smand2

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment