android更改图像视图

时间:2014-10-06 08:17:32

标签: android imageview handler delay each

我使用处理程序来更改每个图像视图" x"秒。我完成了这个,但两个五个图像没有显示时间表明。

从oncreate方法我调用其他方法:showimages();

这是方法showimages()中的一些代码:

    ContextWrapper contextWrapper = new ContextWrapper(getApplicationContext());
    final File directory = contextWrapper.getDir("publi", Context.MODE_PRIVATE);

    handler = new Handler();
    runnable = new Runnable() {
      int i=random;
      public void run() {
        File myfile = new File(directory, "publi"+i+".jpg");
            Log.i("PUBLI", "I want to Show: "+myfile);
            if (myfile.exists()){
            try {
                FileInputStream fis = new FileInputStream(myfile);
                Bitmap b = BitmapFactory.decodeStream(fis);
                publi.setImageBitmap(b);
                Log.i("PUBLI", "SHOWN: "+myfile);
                Toast.makeText(getApplicationContext(), "Loaded.", Toast.LENGTH_SHORT).show();
            } catch (IOException e) {
                e.printStackTrace();
            }
            }
          i++;
          if(i>datos.length)//medir array-1
          {
          i=0;    
          }
          Log.i("ads", "POSTDELAYED INTERVALO");
          handler.postDelayed(runnable, 4000);  //for interval...
      }
  };
 Log.i("ads", "POSTDELAYED initial delay: ");
  handler.postDelayed(runnable, 4000); //for initial delay..*/

}

当我在模拟器中执行此应用程序时,两个图像显示1秒,其他图像显示代码的秒数。

0 个答案:

没有答案