我最近对此感到非常困惑,无法在任何地方找到答案。
在为 android 编程时,我想每 10 秒更新一次 textview,但我该怎么做呢?我已经看到一些示例使用“Run()”和“Update()”,但是当我尝试它时这似乎没有帮助,有什么想法吗?
现在我有:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.slideshow);
CONST_TIME = (int) System.currentTimeMillis();
Resources res = getResources();
myString = res.getStringArray(R.array.myArray);
}
public void checkTime(View V){
TextView text = (TextView) findViewById(R.id.fadequote);
CUR_TIME = (int) System.currentTimeMillis();
text.setText(""+(int) (CUR_TIME-CONST_TIME));//Debugs how much time has gone by
if(CUR_TIME-CONST_TIME>10000){
getNextQuote(null); //A function that gets a random quote
CONST_TIME = CUR_TIME;
}
}
我想我真正要问的是如何让 checkTime() 无休止地重复它,直到 onPause() 被调用?