這可以解決你的問題。
public class ImageSwithcer extends Activity
{
Handler programHandler = new Handler()
{
public void handleMessage(Message msg)
{
/***********
* Update your UI here ****************
*
* like updating your image views
*/
}
};
public void onCreate(Bundle savedInstanceState)
{
super.onCreate();
startImageSwicherThread();
}
public void startImageSwitcherThread()
{
Thread background = new Thread(new Runnable()
{
public void run()
{
try
{
Thread.sleep(4000);
progressHandler.sendMessage(progressHandler.obtainMessage());
}
catch (Exception e)
{
}
}
});
// start the background thread
background.start();
}
}
請嘗試發佈有用的代碼。也許更新你的代碼@ Handler programHandler!= progressHandler [...] - 變量錯配。 – NickFlows 2017-08-21 13:13:25