Android: alpha animation won't start

In my menu, I am trying to implement a button that, when clicked, makes another button using alpha animation.

    final Animation animAlphaUp = new AlphaAnimation(0.0f, 1.0f);
    animAlphaUp.setDuration(200);

    ImageButton start_button = (ImageButton) findViewById(R.id.start_button);
    ImageButton options_button = (ImageButton) findViewById(R.id.options_button);
    final ImageButton mute_button = (ImageButton) findViewById(R.id.options_button);

    options_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mute_button.startAnimation(animAlphaUp);
        }
    });

    mute_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {   
        }
    });

      

but nothing happens when I click the Options button. The animation works, I know this because if I write this:

options_button.setOnClickListener(new View.OnClickListener() {      
    @Override
    public void onClick(View v) {
       options_button.startAnimation(animAlphaUp);
    }
});

      

animation works on the pressed button.

What am I doing wrong?

Thank.

+3


source to share


1 answer


Try using instead your_button_name.startAnimation(your_animation_name);

.



Worked for me.

+1


source







All Articles