How exactly does the android:onClick XML attribute differ from setOnClickListener?

后端 未结 17 2113
野趣味
野趣味 2020-11-21 11:50

From that I\'ve read you can assign a onClick handler to a button in two ways.

Using the android:onClick XML attribute where you just use t

17条回答
  •  梦如初夏
    2020-11-21 12:24

    Supporting Ruivo's answer, yes you have to declare method as "public" to be able to use in Android's XML onclick - I am developing an app targeting from API Level 8 (minSdk...) to 16 (targetSdk...).

    I was declaring my method as private and it caused error, just declaring it as public works great.

提交回复
热议问题