2013-10-22 38 views
0

我有以下代碼:活動顯示烤麪包,但沒有動畫

private Runnable task = new Runnable() { 
    public void run() { 
     Toast.makeText(getApplicationContext(), "Spinner complete!", Toast.LENGTH_LONG).show(); 
     animationFadeIn = AnimationUtils.loadAnimation(MyPhone.this, R.anim.right_slide_in); 
     animationFadeIn.setFillAfter(true); 
     tB.setAnimation(animationFadeIn); 
    } 
}; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.myphone); 
    TextView tB = (TextView) findViewById(R.id.tvBrandName); 

    Handler handler = new Handler(); 
    handler.postDelayed(task, 3000); 
} 

我的XML(代碼的一部分):

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:id="@+id/llBrand" 
    android:weightSum="2" 
    android:layout_weight="1" 
    android:gravity="center" 
    android:background="@drawable/myphoneborder" > 
    <TextView 
     android:id="@+id/tvBrandName" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:layout_weight="1" 
     android:textSize="@dimen/phone_text_size" 
     android:textStyle="bold" 
     android:textColor="#395AFF" 
     android:visibility="invisible" /> 
</LinearLayout> 

slide_in動畫:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator"> 
    <translate 
     android:fromXDelta="100%p" 
     android:toXDelta="0" 
     android:duration="700" 
    /> 
</set> 

我我試圖做的是,等待活動加載並等待3秒鐘並顯示ToastAnimationToast工作正常,但動畫從不顯示。任何想法爲什麼?

回答

1

setAnimation你startAnimation istead。

tB.startAnimation(animationFadeIn); 
+0

DUH !!!!!!!感謝您指出:) – Si8