Android Studio运行小问题1

今天在CSDN中看到一个计算器程序,打算学习一下,在Android Studio运行时下面报错
Error:40, 28 错误: 不兼容的类型: View无法转换为Button
Android Studio运行小错误: 不兼容的类型: View无法转换为Button
网上找了一圈没发现答案(刚刚开始学),只好再次翻书,将报错处代码和书上代码对比,果然发现端倪
contentBtn =(Button)findViewById(R.id.contentBtn)
这是书上的例题代码,原来是报错处的findViewByld前面没加(Button),
Android Studio运行小错误: 不兼容的类型: View无法转换为Button
好吧,不报错了,成功运行。
所以这件事告诉我们:
一定不要直接复制人家的代码,至少要自己检查一遍。
感谢原作者的代码(https://blog.csdn.net/h_lita/article/details/88623319?utm_source=app)

相关文章:

  • 2021-08-04
  • 2021-12-11
  • 2021-10-05
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2022-02-01
猜你喜欢
  • 2021-08-25
  • 2021-10-18
  • 2021-05-28
  • 2022-01-10
  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
相关资源
相似解决方案