How to start Animation immediately after onCreate?

前端 未结 7 1624
借酒劲吻你
借酒劲吻你 2020-12-15 06:58

I am following http://developer.android.com/guide/topics/graphics/view-animation.html#frame-animation with minor changes. I have decided to make the animation loop and want

相关标签:
7条回答
  • Run this in onResume():

    class AnimTask extends AsyncTask<String, String,String> {
                Activity act;
                AnimTask(Activity act) {
                    this.act = act;
                }
    
                @Override
                protected String doInBackground(String... params) {
                    act.runOnUiThread(new Runnable() {
                        public void run(){
                            animImg = (ImageView)findViewById(R.id.listen_anim);
                            animImg.setBackgroundResource(R.drawable.listening);
                            anim = (AnimationDrawable) animImg.getBackground();
                            anim.start();
                        }
                    });
                    return null;
                }
            }
    
    0 讨论(0)
提交回复
热议问题