【问题标题】:FrameLayout cannot be cast to TextView, weird ClassCastExceptionFrameLayout 无法转换为 TextView,奇怪的 ClassCastException
【发布时间】:2013-10-08 22:40:47
【问题描述】:

我的应用程序抛出了一个奇怪的异常。 LogCat 输出显示:

java.lang.ClassCastException: android.widget.FrameLayout cannot be converted to  android.widget.TextView.

这个异常是由这一行引起的:

TextView distance = (TextView) findViewById(R.id.distance);

R.id.distance 绝对指的是 TextView,我不知道如何抛出这个异常。 所以我的问题是,你们中是否有人遇到过类似的问题并且知道解决此问题的方法。

【问题讨论】:

  • 一定是资源ID冲突,尝试清理/构建你的项目

标签: android textview classcastexception android-framelayout


【解决方案1】:

尝试再次清理并构建您的项目。如果您使用的是 Eclipse,当 Eclipse 无法正确构建资源 id 时,这种情况会时有发生。

【讨论】:

  • 谢谢你,解决了我的问题 :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-04
  • 2012-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多