當我點擊一個按鈕,我想改變,在500毫秒,按鈕backgourndimage並做一個簡短的動畫。我已經完成了一段代碼,但是我看不到relsult,動畫沒問題,但點擊的圖片按鈕沒有出現。如何更改並查看按鈕背景圖像幾毫秒?
的defalut按鈕圖像 「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型動物
添加計時器和運行方法設置背景圖片 –