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 秒并显示ToastAnimation. 工作正常,Toast但动画从不显示。知道为什么吗?

4

1 回答 1

1

你 startAnimation 而不是 setAnimation。

tB.startAnimation(animationFadeIn);
于 2013-10-22T19:20:57.500 回答