translate.animate
進行中にボタンをクリックできないようにする方法。私は試してみましたがbutton.setclickable(false)
、button.setEnabled(false)
どちらもうまくいきました。
これが私のコードです:
b2.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
if(i%2==0)
{
//b2.setClickable( false );
// Toast toast1 = Toast.makeText(getBaseContext(), "Success", 1);
// toast1.show();
if(i==0)
{
//b2.setOnClickListener(null);
b2.setEnabled(false);
//b2.setClickable(false);
int modifierY;
modifierY=-70;
Animation translateAnimation=new TranslateAnimation(0, 0, 0, modifierY);
translateAnimation.setDuration(600);
translateAnimation.setFillEnabled(true);
MyAnimationListener listener=new MyAnimationListener(b2, modifierY,SimpleViewPagerforAndroidActivity.this);
translateAnimation.setAnimationListener(listener);
// b2.setOnClickListener(null);
Animation translateAnimation1=new TranslateAnimation(0, 0, 0,0 );
translateAnimation1.setDuration(1000);
translateAnimation1.setFillEnabled(true);
MyAnimationListener listener1=new MyAnimationListener(main, 0,SimpleViewPagerforAndroidActivity.this);
translateAnimation1.setAnimationListener(listener1);
main.setVisibility(RelativeLayout.VISIBLE);
/* long time =AnimationUtils.currentAnimationTimeMillis();
main.invalidate();
b2.invalidate();
translateAnimation.setStartTime(time);
translateAnimation1.setStartTime(time);*/
main.startAnimation(translateAnimation1);
b2.startAnimation(translateAnimation);
i++;
// b2.setOnClickListener(this);
}
else
{
//b2.setOnClickListener(null);
b2.setEnabled(false);
//b2.setClickable(false);
int modifierY;
modifierY=-70;
Animation translateAnimation=new TranslateAnimation(0, 0, 0, modifierY);
translateAnimation.setDuration(1000);
translateAnimation.setFillEnabled(true);
MyAnimationListener listener=new MyAnimationListener(b2, modifierY,SimpleViewPagerforAndroidActivity.this);
translateAnimation.setAnimationListener(listener);
Animation translateAnimation1=new TranslateAnimation(0, 0, 0,-150 );
translateAnimation1.setDuration(600);
translateAnimation1.setFillEnabled(true);
MyAnimationListener listener1=new MyAnimationListener(main, -150,SimpleViewPagerforAndroidActivity.this);
translateAnimation1.setAnimationListener(listener1);
main.setVisibility(RelativeLayout.VISIBLE);
/* long time =AnimationUtils.currentAnimationTimeMillis();
main.invalidate();
b2.invalidate();
translateAnimation.setStartTime(time);
translateAnimation1.setStartTime(time);*/
main.startAnimation(translateAnimation1);
b2.startAnimation(translateAnimation);
// b2.setOnClickListener(this);
i++;
}
}
else
{
//b2.setOnClickListener(null);
b2.setEnabled(false);
//b2.setClickable(false);
Animation translateAnimation=new TranslateAnimation(0, 0, 0,150 );
translateAnimation.setDuration(1000);
translateAnimation.setFillEnabled(true);
MyAnimationListener listener=new MyAnimationListener(main, 150,SimpleViewPagerforAndroidActivity.this);
translateAnimation.setAnimationListener(listener);
Animation translateAnimation1=new TranslateAnimation(0, 0, 0,70 );
translateAnimation1.setDuration(600);
translateAnimation1.setFillEnabled(true);
MyAnimationListener listener1=new MyAnimationListener(b2, 70,SimpleViewPagerforAndroidActivity.this);
translateAnimation1.setAnimationListener(listener1);
/* long time =AnimationUtils.currentAnimationTimeMillis();
main.invalidate();
b2.invalidate();
translateAnimation.setStartTime(time);
translateAnimation1.setStartTime(time);
main.startAnimation(translateAnimation1);
b2.startAnimation(translateAnimation);*/
b2.startAnimation(translateAnimation1);
main.startAnimation(translateAnimation);
i++;
//b2.setOnClickListener(this);
}
}
});