为什么animationDrawable.start();不能在onCreate 里执行

rabbitinhere 2013-03-06 09:52:50
或onStart或onResume也不行。
求解。
...全文
152 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jack_Kee 2013-10-08
  • 打赏
  • 举报
回复
public void start () Added in API level 1 Starts the animation, looping if necessary. This method has no effect if the animation is running. Do not call this in the onCreate(Bundle) method of your activity, because the AnimationDrawable is not yet fully attached to the window. If you want to play the animation immediately, without requiring interaction, then you might want to call it from the onWindowFocusChanged(boolean) method in your activity, which will get called when Android brings your window into focus.
rabbitinhere 2013-03-06
  • 打赏
  • 举报
回复
animationDrawable是一个AnimationDrawable(废话……) 定义如下: imageView.setBackgroundResource(R.drawable.anim_list); animationDrawable=(AnimationDrawable)imageView.getBackground(); ---------------放在一个监听器就能播放动画-------------------------------- imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub animationDrawable.start(); } }); ---------------放在一个onCreate里就不行-------------------------------- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); animationDrawable.start(); }
rabbitinhere 2013-03-06
  • 打赏
  • 举报
回复
呀喝,你也喜欢有码的?
xn4545945 2013-03-06
  • 打赏
  • 举报
回复
无码无真相。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧