如何在Ontick中实现带有inimation的textSwitcher

时间:2016-01-04 03:23:16

标签: text textview countdowntimer switchers

我正在创建一个代码来显示文本动画(从上到下滑动),并且文本每秒都在变化,我使用的是CountDownTimer和textSwitcher。 请参考下面的代码。

代码正常编译,但是一旦我尝试访问包含textswitcher的活动,它就会崩溃应用程序。

 final TextSwitcher sec_sw = (TextSwitcher)findViewById(R.id.textSwitcher);
    sec_sw.setInAnimation(this, R.anim.slide_in_bottom);
    sec_sw.setOutAnimation(this, R.anim.slide_out_top);

    new CountDownTimer(differenceleft, 1000) { // adjust the milli seconds here

        public void onTick(long millisUntilFinished) {
            days_tv.setText(""+String.format("%02d", TimeUnit.MILLISECONDS.toDays(millisUntilFinished)));
            hours_tv.setText(""+String.format("%02d",TimeUnit.MILLISECONDS.toHours(millisUntilFinished)- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(millisUntilFinished))));
            min_tv.setText("" + String.format("%02d", TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millisUntilFinished))));
            //sec_tv.setText("" + String.format("%02d", TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))));
            sec_sw.setText("" + String.format("%02d", TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))));

        }
        public void onFinish() {
            /*_tv.setText("done!");*/
        }
    }.start();

0 个答案:

没有答案