変更したいボタンをクリックすると、500ミリ秒の間にボタンの背景画像が表示され、短いアニメーションが表示されます。コードを作成しましたが、結果が表示されません。アニメーションは問題ありませんが、クリックした画像ボタンが表示されません。
デフォルトのボタン画像は「boutton_a.png」 クリックされたボタン画像は「button_a_ok.png」
onclick ボタンのコードは次のとおりです。
if (Button04.getText().equals(Reponse)){
Button01.setBackgroundResource(R.drawable.boutton_a_ok);
AnimationSet set=new AnimationSet(true);
Animation animation=new TranslateAnimation(Animation.RELATIVE_TO_SELF,10,Animation.RELATIVE_TO_SELF,10);
animation.setDuration(100);
set.addAnimation(animation);
Button01.startAnimation(set);
}else{
Button01.setBackgroundResource(R.drawable.boutton_a_nok);
AnimationSet set=new AnimationSet(true);
Animation animation=new TranslateAnimation(Animation.RELATIVE_TO_SELF,10,Animation.RELATIVE_TO_SELF,10);
animation.setDuration(100);
set.addAnimation(animation);
Button04.startAnimation(set);
}
どのようにできるのか ?
編集:2つのbackgroundressourcesの違いがあるため、すべてのコードを投稿しました