更改使用runOnUiThread图像 [英] change the images using runOnUiThread
问题描述
您好我是显示2 imageViews如果一个图像包含数字1(数字1图像)第二图像显示2(图片2)
并再次第一个图像displayt 2图像(编号2),那么第二个ImageView的显示图像3(3号图片)
dispalying.for这第一个图像的一段时间后,显示第二图像视图我使用runOnUiThread concept.Please给我一些建议,以两个线程如何在runOnUiThread方法写。给提前一些样本code.Thanks。
Hi i am displaying the 2 imageViews if one image contain number 1(number1 image) second image show 2(image 2) and again first image displayt the 2 image(number2) then second imageview display the 3 image(number 3 image) second image view is displayed after some time of first image dispalying.for this i am using runOnUiThread concept.Please give me some suggestions to how two threads are write in runOnUiThread method .Give some sample code.Thanks in advance.
推荐答案
这可以解决你的问题。
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();
}
}
这篇关于更改使用runOnUiThread图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!