TextView Marquee不会使用Handler滚动

时间:2013-09-18 14:15:29

标签: android

我目前正在使用带有计时器的TextView选框(通过Handler)。这是我的代码:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.game);
        text = (TextView)findViewById(R.id.text);
        text.setSelected(true);
        text.setText("hahahahahahahahaha");

        timerValue = (TextView) findViewById(R.id.timer);
        startTime = SystemClock.uptimeMillis();
        customHandler.postDelayed(updateTimerThread, 0);
        timerValue.setSelected(false);
        text.setSelected(true);
        text.requestFocus();
    }
    private Runnable updateTimerThread = new Runnable() {
                public void run() {

                    timeInMilliseconds = SystemClock.uptimeMillis() - startTime;
                    updatedTime = timeSwapBuff + timeInMilliseconds;
                    int secs = (int) (updatedTime / 1000);
                    int mins = secs / 60;
                    secs = secs % 60;
                    int milliseconds = (int) (updatedTime % 1000);
                    timerValue.setText("" + mins + ":"
                            + String.format("%02d", secs) + ":"
                            + String.format("%03d", milliseconds));
                    customHandler.postDelayed(this, 0);
                }
            };
如果我禁用customHandler.postDelayed(updateTimerThread, 0);

Marquee工作正常。但如果它同时运行(使用我的计时器(00:00:00)),文本将不会滚动。这是我的TextView布局:

我已经尝试设置setSelected(true)但仍然没有运气。

0 个答案:

没有答案