<!-- Name of the method in this View's context to invoke when the view is clicked. This name must correspond to a public method that takes exactly one parameter of type View. For instance, if you specify <code>android:onClick="sayHello"</code>, you must declare a <code>public void sayHello(View v)</code> method of your context (typically, your Activity). --> <attrname="onClick"format="string" />
注释告诉我们,它的命名规则必须是,在 Context 中的 public 方法,并且必须传递一个 View 参数:
/** * An implementation of OnClickListener that attempts to lazily load a * named click handling method from a parent or ancestor context. */ privatestaticclassDeclaredOnClickListenerimplementsOnClickListener{ privatefinal View mHostView; privatefinal String mMethodName;