开发者

change the images using runOnUiThread

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 开发者_C百科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.


This can solve your problem.

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();
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜