Android: <declare-styleable> method attributes
问题 How does one accept methods as values, in attributes? Like in the onClick attribute for a View: <Button android:onClick="onClickMethod"/> How to define custom attributes that accept methods? I know we use <declare-styleable> in resources, but how do we make it accept methods? 回答1: Android uses reflection to find the name of the method and invoke it. You can see an example in the source starting at line 4209 https://github.com/android/platform_frameworks_base/blob/master/core%2Fjava%2Fandroid