1

TableRowを次のように膨らませます。

final TableRow tr1 = (TableRow)LayoutInflater.from(this).inflate(R.layout.attrib_row_survey, null);
tr1.setOnTouchListener(this);
tl1.addView(tr1);

これが私のカウンターのやり方です:

new CountDownTimer(30000, 1000) {

                 public void onTick(long millisUntilFinished) {
                     ((TextView)tr1.findViewById(R.id.textView2)).setText("Seconds Remaining: " + millisUntilFinished / 1000);
                 }

                 public void onFinish() {
                     ((TextView)tr1.findViewById(R.id.textView2)).setText("DONE");
                 }
              }.start();

問題は、このタイマーを実行して行に表示すると、UIが非常に遅くなり、タイマーが遅れることです。onTouchListener()でview.setBackGroundColor(Color.BLACK)を実行してクリックすると、遅れます。

4

1 に答える 1

0
protected static void startTimer() {
    isTimerRunning = true; 
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            elapsedTime += 1; //increase every sec
            mHandler.obtainMessage(1).sendToTarget();

        }
    }, 0, 1000);
}

   public Handler mHandler = new Handler() {

     public void handleMessage(Message msg) {
           StopWatch.time.setText(formatIntoHHMMSS(elapsedTime)); //this is the textview
     }
    }
于 2012-12-12T05:56:08.487 に答える