InflateException: Couldn't resolve menu item onClick handler

后端 未结 7 789
情书的邮戳
情书的邮戳 2020-12-08 19:12

I asked this question 6 years ago. In the meantime Android development best practices have changed, and I have become a better developer.

Since then, I have realized

7条回答
  •  再見小時候
    2020-12-08 19:44

    In my case the problem was that I had both onClick in my menu XML and an onCreateOptionsMenu in my Activity. My onClick was actually faulty (because it pointed to non-existent methods) but I didn't notice this at first because I was testing under Android 2.x, where onClick is not supported and ignored. Once I tested on 4.x though, I started getting this error.

    So basically, don't use onClick if you plan on deploying under Android 2.x. It will silently ignore your onClick values until you try running on 3.0+.

提交回复
热议问题