我有一个类,我在其中设置了XML布局的ContentView
setContentView(R.layout.car_layout);
然后设置所有成员:
text1 = (TextView) findViewById(R.id.text1);
text2 = (TextView) findViewById(R.id.text2);
textCar = (TextView) findViewById(R.id.textCar);
textId = (TextView) findViewById(R.id.textId);
一切都符合,但在运行时我遇到崩溃错误,说R.id.textCar
是null
,但该字段存在100%,并且它在R.java
文件中也有值。我尝试更改名称但仍返回null
。
试图清理项目,重建它,删除.iml
......没有发生任何事情。
可能是什么问题? (我使用Android Studio)