2014-06-21 100 views
-1

在這裏,我有動畫自定義的TextView之前刪除的TextView:重新創建

badge7 = new BadgeView(this,findViewById(R.id.action_contact)); 
     badge7.hide(); 
     badge7.setTextColor(Color.BLUE); 
     badge7.setBadgeBackgroundColor(Color.YELLOW); 
     text++; 
     badge7.setText(String.valueOf(text)); 
     badge7.setTextSize(12); 
     badge7.setBackgroundResource(R.drawable.badge_ifaux); 
     badge7.setBadgePosition(BadgeView.POSITION_TOP_LEFT); 
     badge7.setBadgeMargin(15, 10); 


     TranslateAnimation anim = new TranslateAnimation(-100, 0, 0, 0); 
     anim.setInterpolator(new BounceInterpolator()); 
     anim.setDuration(2000); 
     anim.cancel(); 
     badge7.toggle(anim, null); 

的問題是每當動畫會再次播放,我需要的最後一個從屏幕上消失,但我不能讓它發生了什麼,這樣做的正確方法是什麼?

回答

0

很好,找到了解決辦法:

if(badge7!=null){ 
     badge7.setVisibility(View.GONE); 
     badge7.invalidate(); 
     }