1

我目前正在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);
                }
            };

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

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

4

0 回答 0