Android Constant expression required (case R.id.xxx)

gradle更新到8.0后,遇到了这个报错

有两种解决方式:

1、在gradle.properties中添加下面代码

android.nonFinalResIds=false

2、使用if-else来判断

int id = view.getId();
if (id == R.id.setting_iv_back) {
            
} else if (id == R.id.setting_tv_clear) {
            
}

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 19:12:04       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 19:12:04       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 19:12:04       57 阅读
  4. Python语言-面向对象

    2024-07-10 19:12:04       68 阅读

热门阅读

  1. Spring Boot与Apache Kafka Streams的集成

    2024-07-10 19:12:04       22 阅读
  2. uniapp 封装瀑布流组件

    2024-07-10 19:12:04       23 阅读
  3. ubuntu22安装Docker并配置

    2024-07-10 19:12:04       21 阅读
  4. 在Ubuntu上用Docker轻松实现GPU加速的TensorFlow

    2024-07-10 19:12:04       24 阅读
  5. Dockerfile 怎么在shell脚本中启动

    2024-07-10 19:12:04       25 阅读