Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中使用搜索栏控制帧动画速度_Android_Eclipse - Fatal编程技术网

android中使用搜索栏控制帧动画速度

android中使用搜索栏控制帧动画速度,android,eclipse,Android,Eclipse,我有下面的代码,在seekbar的帮助下改变了帧动画的不透明度,现在我正试图通过这个搜索栏来控制帧动画的持续时间,有人能帮我告诉我这是可能的吗 守则: ImageView myAnimation = (ImageView)findViewById(R.id.myanimation); //Create a new AnimationDrawable final AnimationDrawable myAnimationDrawable

我有下面的代码,在seekbar的帮助下改变了帧动画的不透明度,现在我正试图通过这个搜索栏来控制帧动画的持续时间,有人能帮我告诉我这是可能的吗

守则:

ImageView myAnimation = (ImageView)findViewById(R.id.myanimation);

        //Create a new AnimationDrawable
        final AnimationDrawable myAnimationDrawable 
            = createAnimationDrawable();

        //apply the new AnimationDrawable
        myAnimation.setImageDrawable(myAnimationDrawable);

        SeekBar setAnimationAlpha = (SeekBar)findViewById(R.id.setalpha);
        Button startAnimation = (Button)findViewById(R.id.startanimation);
        Button stopAnimation = (Button)findViewById(R.id.stopanimation);

        startAnimation.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                if(!myAnimationDrawable.isRunning()){
                    myAnimationDrawable.start();
                }
            }});

        stopAnimation.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                if(myAnimationDrawable.isRunning()){
                    myAnimationDrawable.stop();
                }
            }});

        setAnimationAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {
                myAnimationDrawable.setAlpha(progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }});

    }

    private AnimationDrawable createAnimationDrawable(){

        AnimationDrawable newAnim = new AnimationDrawable();

        newAnim.addFrame(getResources().getDrawable(R.drawable.android_1), 90);
        newAnim.addFrame(getResources().getDrawable(R.drawable.android_2), 90);
        newAnim.addFrame(getResources().getDrawable(R.drawable.android_3), 90);
        newAnim.addFrame(getResources().getDrawable(R.drawable.android_4), 90);
        newAnim.addFrame(getResources().getDrawable(R.drawable.android_5), 90);
        newAnim.addFrame(getResources().getDrawable(R.drawable.android_6), 90);
        newAnim.addFrame(getResources().getDrawable(R.drawable.android_7), 90);
        newAnim.setOneShot(false);

        return newAnim;
    }

}