使用某些动画完成Timer时删除列表行

时间:2015-10-20 13:54:26

标签: android android-listview android-animation countdowntimer

如何在计时器完成时使用某种动画删除列表行。我已经尝试了下面的代码,但它无法正常工作请检查一下,请让我知道我在哪里做错了。

这是我在适配器getview()方法中的代码

final TextView tv = holder.timer;

                CountDownTimer cdt = counters.get(tv);
                if(cdt!=null)
                {
                    cdt.cancel();
                    cdt=null;
                }

                cdt = new CountDownTimer(Long.parseLong(product.getOfferEndTime()), 1000)
                {
                    @Override
                    public void onTick(long millisUntilFinished) 
                    {

                        int minutes = 0;
                        int seconds = 0;
                        String sDate = "";

                        if(millisUntilFinished > DateUtils.MINUTE_IN_MILLIS)
                        {
                            minutes = (int) (millisUntilFinished / DateUtils.MINUTE_IN_MILLIS);
                        }

                        millisUntilFinished -= (minutes*DateUtils.MINUTE_IN_MILLIS);

                        if(millisUntilFinished > DateUtils.SECOND_IN_MILLIS)
                        {
                            seconds = (int) (millisUntilFinished / DateUtils.SECOND_IN_MILLIS);
                        }

                        sDate += " "+"00"+":"+String.format("%02d",minutes)+":"+String.format("%02d",seconds);
                        tv.setText(sDate.trim());
                    }

                    @Override
                    public void onFinish() {


                        tv.setText("Finished");

                        removeListItem(v,position) ;    

                    }
                };

这是我在适配器类

中的removeListItem方法
protected void removeListItem(View rowView, final int positon) {
        final Animation animation = AnimationUtils.loadAnimation(
                context, android.R.anim.slide_in_left);
        rowView.startAnimation(animation);
        Handler handle = new Handler();
        handle.postDelayed(new Runnable() {

            public void run() {
                ListOnGoing.productListAdapter.remove(getItem(positon));
                ListOnGoing.productListAdapter.notifyDataSetChanged();
            }
        }, 1000);
}

请帮我解决这个问题。谢谢

0 个答案:

没有答案