android编程常见问题- Resource ID #0x7f070001 type #0x12 is not valid

时间:2023-03-09 07:55:45
android编程常见问题- Resource ID #0x7f070001 type #0x12 is not valid

问题说明:

AndroidRuntime(1705): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.activitytest/com.example.activitytest.SecondActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f070001 type #0x12 is not valid

解决办法:

根据Resource ID #0x7f070001 type #0x12 is not valid 提示,去R.java 文件中检查是否定义该对象,

android编程常见问题- Resource ID #0x7f070001 type #0x12 is not valid

如果已经定义,则检查com.example.activitytest.SecondActivity类

  android编程常见问题- Resource ID #0x7f070001 type #0x12 is not valid

发现语句写错了,改为:setContentView(R.layout.second_layout);解决问题