找不到符号:方法findViewByID(int)

huangapple go评论111阅读模式
英文:

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,

huangapple
  • 本文由 发表于 2020年9月5日 13:19:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63750688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定