Есть код:
Код | class ButtonsAnimationRunner implements Runnable { ImageButton imgButton; int imgButtonResourceUp; int imgButtonResourceDown; int millisecs; int periodMillisecs; public ButtonsAnimationRunner(int milliseconds, ImageButton button, int buttonResourceUp, int buttonResourceDown, int TimerPeriod) { imgButton = button; imgButtonResourceUp = buttonResourceUp; imgButtonResourceDown = buttonResourceDown; millisecs = milliseconds; periodMillisecs = TimerPeriod; } public void run() { try { imgButton.setImageResource(R.drawable.colorbutton1down); Thread.sleep(1000, 0); imgButton.setImageResource(imgButtonResourceUp); } catch (InterruptedException ex) { Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex); } } }
|
Это на самом деле код для андроида. Получаю ошибку в строках:
Код | ... try { imgButton.setImageResource(R.drawable.colorbutton1down); Thread.sleep(1000, 0); imgButton.setImageResource(imgButtonResourceUp); } catch (InterruptedException ex) { ...
|
Эта ошибка связана с тем что здесь идет обращение к элементам пользовательского интерфейса из потока. Какой прием надо использовать чтобы обращаться к пользовательскому интерфейсу? |