英文:
Cannot find symbol: method findViewByID(int)
问题
已经试图解决问题两个小时了。我看到并尝试过的解决方法如下:
- 使缓存无效/重新启动
- getView().findViewByID(R.id.button) 或 rootView.findViewById(R.id.button)
- 大小写
Button popUp = (Button) findViewByID(R.id.button);
任何帮助将不胜感激,谢谢。
英文:
Been trying to figure out the problem for the last two hours. The solutions I have seen and tried are as follows:
-
Invalidate caches/restart
-
getView().findViewByID(R.id.button) or rootView.findViewById(R.id.button)
-
Casing
Button popUp = (Button) findViewByID(R.id.button);
This is the video that I was following to create this.
Any help would be greatly appreciated, thank you.
答案1
得分: 1
用这个替换:
Button popUp = (Button) findViewById(R.id.button);
在 Android 中,不允许写成 findViewByID
,要写成 findViewById
。
英文:
Replace
Button popUp = (Button) findViewByID(R.id.button);
with this
Button popUp = (Button) findViewById(R.id.button);
You are writing findViewByID it's not allowed in android write findViewById
答案2
得分: 0
https://www.bugsnag.com/blog/how-to-make-sense-of-android-crash-logs
我认为这篇文章会对像这样查找错误的情况非常有用。你很可能在运行日志中的确切行上抛出了一个错误,在这个问题的确切位置,这迫使你查看了你错误的地方。
但就像评论中所说的那样,你有一个简单的拼写错误。你的错误处的单词变红了吗?如果没有,我建议尝试使用另一个集成开发环境,比如Android Studio。
祝好,
英文:
https://www.bugsnag.com/blog/how-to-make-sense-of-android-crash-logs
I think this is an article that would prove very useful to find errors like that. You were probably throwing an error in your run log at the exact line you had this issue at, which forces you to look at the exact spot of your mistake.
But like the comment on it said, you had a simple typo. Wasn't the word with your mistake turning red? If not I'd try a different IDE such as android studio.
Regards,
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论