gpt4 book ai didi

android - 使用线程的间隔重绘 View

转载 作者:太空狗 更新时间:2023-10-29 14:25:21 28 4
gpt4 key购买 nike

我需要自定义 View 中的动画菜单。必须每隔一段时间(大约10次)重绘,但线程停止后重绘。

public void menuShift() {
Runnable runnable = new Runnable() {
public void run() {
while (TablesActivity.this.view.menuShifting) {
try {
Thread.sleep(100) ;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TablesActivity.this.view.timerRefresh() ;
TablesActivity.this.view.postInvalidate() ;
}
}
} ;
this.menuShiftThread = new Thread(runnable) ;
this.menuShiftThread.run() ;
}

最佳答案

this.menuShiftThread.run();是问题,你需要

this.menuShiftThread.start()

实际开始一个新线程。

关于android - 使用线程的间隔重绘 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13146119/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com