我正在尝试在主要活动中实现 Timer()。但是,不知何故,它并没有像我预期的那样工作。我将向您展示关键代码部分。错误:图标未更改
public class X extends Activity {
private Timer timer = new Timer () ;
setContentView(R.layout.main);
public void onCreate(Bundle a) {
//..
timer.scheduleAtFixedRate( new Device(), 1000, 1000 );
}
}
public class Device extends TimerTask {
Image e;
View w;
public void run() {
e = ( ImageView ) w.findViewById(R.id.imageView1);
if ( isVolited ( ))
e.setBackground(w.getResources().getDrawable(R.drawable.icon1));
else
e.setBackground(w.getResources().getDrawable(R.drawable.icon2));
日志 :
01-29 14:25:51.175: E/TabletStatusBar(2172): closing mini mode apps panel
01-29 14:25:51.255: E/TabletStatusBar(2172): closing mini mode apps panel
01-29 14:25:56.510: E/lights(2051): write_int failed to open /sys/class/sec/sec_touchkey/brightness
01-29 14:25:59.105: E/lights(2051): write_int failed to open /sys/class/sec/sec_touchkey/brightness
01-29 14:26:00.060: E/TODmobile(3509): onReceive action=android.intent.action.TIME_TICK
01-29 14:26:00.060: E/TODmobile(3509): hour : 14 minute : 26
01-29 14:26:00.060: E/DigitalClockWidget(3509): updateWidgets
01-29 14:26:00.065: E/TODmobile(3509): hour : 14 minute : 26
01-29 14:26:10.725: E/Watchdog(2051): !@Sync 504