android - 二进制XML文件第3行: Error inflating class animation-list

标签 android error-handling android-animation

我试图将动画添加到我调用此类时运行的xml文件中

public class anim extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.anim.anim);
ImageView img = (ImageView)findViewById(R.anim.anim);
img.setBackgroundResource(R.anim.anim);
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
frameAnimation.start();
}
}

这是xml文件
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"  >

<item android:drawable="@drawable/bee00" android:duration="50" />
<item android:drawable="@drawable/bee01" android:duration="50" />
<item android:drawable="@drawable/bee02" android:duration="50" />
<item android:drawable="@drawable/bee03" android:duration="50" />
<item android:drawable="@drawable/bee04" android:duration="50" />
<item android:drawable="@drawable/bee05" android:duration="50" />
 <item android:drawable="@drawable/bee06" android:duration="50" />
  <item android:drawable="@drawable/bee07" android:duration="50" />
   <item android:drawable="@drawable/bee08" android:duration="50" />
    <item android:drawable="@drawable/bee09" android:duration="50" />
     <item android:drawable="@drawable/bee10" android:duration="50" />
</animation-list>

当我运行我的应用程序时
Binary XML file line #3: Error inflating class animation-list 

在LogCat窗口上,任何人都知道吗?

最佳答案

这是因为当应改用menu.xml文件(如documentation中所述)时,会用Animation xml文件的内容为偏好屏幕充气。

另外,当您在布局中找到特定 View 时,也应使用保存在R.id中的ID值

然后,如果要使用帧动画,则应创建xml文件并将其存储在res/drawable文件夹中,然后在设置图像的背景资源时使用R.drawable.filename在代码中引用它。也请参阅this文档。

关于android - 二进制XML文件第3行: Error inflating class animation-list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9016959/

相关文章:

visual-c++ - WinRT-Windows应用商店-WinRT原始错误-如何解密此类错误?

php - 引用 - 这个错误在 PHP 中是什么意思?

添加反向动画时 Android 动画显示空白 View

android - 更改 ActionBar 隐藏动画?

php - HttpKernel\Exception\MethodNotAllowedHttpException : The GET method is not supported for this route. Supported methods: POST in Laravel

android - Android 中类似 Twitter 的闪屏动画

android - 使用 RenderScript 支持库获取 "cannot locate symbol _Z17rsMatrixTranslateP12rs_matrix4x4fff"?

java - 异常调度输入事件

android - 如何在 android 房间中表示嵌套的一对多关系?

android - 成功从 Rest 客户端获取 400 volley 服务器错误