0

我有一个列表视图,其中的条目在用户删除\编辑列表中的条目时具有淡出动画。

出于某种原因,在我执行操作(编辑\删除)之后,动画将不会开始,直到我再次按下屏幕。只有他们才能真正执行动画。

从此方法调用动画:

public void replace(View view, long position) {
    int hoursSum = 0;
    int minuteSum = 0;
    boolean hoursIssue = false;

    if (finsihIntMinutes >= startIntMinutes) {
        minuteSum = finsihIntMinutes - startIntMinutes;

    } else if (finsihIntMinutes < startIntMinutes) {
        minuteSum = (finsihIntMinutes + Utility.MINUTES_TIME_UNIT)
                - startIntMinutes;
        hoursIssue = true;
    }

    if (finishIntHours >= startIntHours) {
        hoursSum = finishIntHours - startIntHours;
        if (hoursIssue == true) {
            --hoursSum;
        }
    } else if (finishIntHours < startIntHours) {

        hoursSum = (finishIntHours + Utility.HOURS_TIME_UNIT)
                - startIntHours;
    }

    double salper = (minuteSum * Main.sal) / 60;
    double salper2 = hoursSum * (Main.sal);
    String madeSoFar = ""
            + String.valueOf(formatter.format(salper2 + salper));
    String edited = "**Edited**";

    String totalTime = "" + hoursSum + ":" + minuteSum;

    DB.edit(position, Shifts.editDate, Shifts.editStartTime,
            Shifts.editEndTime, Shifts.dayString, totalTime, minuteSum,
            madeSoFar, edited, totalHours, totalMinutes);

    moneySummary = getMoney();
    hoursSummary = "Total Hours: " + getHours();
    summary.setText(moneySummary);

    **FastScrollAdapter.animate(Shifts.view);**

}

这是动画代码:

public static void animate(final View v) {

    Animation out = new AlphaAnimation(1, 0);
    out.setInterpolator(new DecelerateInterpolator());
    out.setDuration(350);
    v.setAnimation(out);
    out.start();
    out.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            Log.i("Animation", "Started");
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

            // Shifts.setSummaryCursor.requery();
            Shifts.getMoneyCursor.requery();
            FastScrollAdapter.cursor.requery();
            Shifts.CA.notifyDataSetChanged();

        }

        @Override
        public void onAnimationEnd(Animation animation) {

            // Shifts.setSummaryCursor.requery();
            Shifts.getMoneyCursor.requery();
            FastScrollAdapter.cursor.requery();
            Shifts.CA.notifyDataSetChanged();
            Log.i("Animation", "Ended");

        }
    });

}
4

3 回答 3

6

我遇到了完全相同的问题,我通过调用解决了它

view.clearAnimation();

就在之前

view.startAnimation(animation);
于 2013-06-12T00:04:45.867 回答
0

我有一个类似的问题:动画没有在 UE 线程中执行。尝试运行在 UE 主题中发布的动画:

                mHandler.post(new Runnable() {
                @Override
                public void run() {
                    yourView.startAnimation(yourAnimation));
                }
            });
于 2012-09-17T15:37:44.837 回答
0

我认为您需要更改订单

1. v.setAnimation(out);
2. out.setAnimationListener(new AnimationListener()); 
3. v.startAnimation(out);
于 2012-09-04T14:59:48.320 回答