onLongclick,文本视图应该每隔一分钟将其值增加1

时间:2017-02-23 16:17:36

标签: java android timer

onLongClickonLongLouch一个TextView,我需要每60秒将其值增加1,如下所示:

 <TextView
    android:layout_width="match_parent"
    android:text="00 min"
    android:id="@+id/timer"
    android:layout_height="120dp"
    />

1 个答案:

答案 0 :(得分:0)

创建一个以毫秒为单位运行的计时器。

 final Handler handlerIncrementar = new Handler();
Timer timerTexto = new Timer();
TimerTask tareaEjecucion = new TimerTask() {
    @Override
    public void run() {
        handlerIncrementar.post(new Runnable() {
            public void run() {
                try {
                    yourtextview.setTextSize(yourtextview.getTextSize() + 1);
                } catch (Exception e) {
                }
            }
        });
    }
};
timerTexto.schedule(tareaEjecucion, 0, 60000);