【发布时间】:2016-02-20 09:27:00
【问题描述】:
我的安卓程序中有一个计时器:
timer1= new Timer();
timer1.schedule(new TimerTask() {
@Override
public void run() {
TimerMethod();
}
}, 0, 3000);
private void TimerMethod()
{
this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable() {
public void run() {
//my code
}}
我想从 TimerMethod 向 Timer_Tick 发送一个参数,换句话说,我想要一个 Timer_Tick 的输入参数,
我将代码更改为:
int input1=10;
timer1= new Timer();
timer1.schedule(new TimerTask() {
@Override
public void run() {
TimerMethod(input1);
}
}, 0, 3000);
private void TimerMethod(int myinput)
{
this.runOnUiThread(Timer_Tick);
//How pass myinput to Timer_Tick????????????
}
我该怎么办?
【问题讨论】:
-
那添加有什么问题?
标签: android timer parameters ui-thread