Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is happening because you are placing the new image within the holder and calling invalidate to make it display but then you turn around and put the UI thread to sleep for 5 seconds so I cannot update it. By the time the system goes to update it, it is already moving on to the next image. I would use a AsyncTask to load the next Image in the background and then put a timer of 5 seconds in the the background thread before it updates the UI with the new data.</p> <p><strong>EDIT</strong><br> Here is the reworked version of your code that is operational if this is your exact code. If not you should be fine. (if the formatting is bad, it is because my work uses IE8 still and it doesn't let me see the formatting. I will fix when I get home.)</p> <pre><code>public class MyImageActivity extends Activity { private final String TAG = "MyImageActivity"; private ImageView mIV; @Override public void onCreate(Bundle savedInstanceState) { Log.e(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.mylayout); mIV = (ImageView) findViewById(R.id.image_display); } @Override protected void onResume() { Log.e(TAG, "onResume"); super.onResume(); } public void pressedStart(View view) { new SlideShowTask().execute(); } private class SlideShowTask extends AsyncTask&lt;Void, Drawable, Void&gt;{ private Bitmap mFaceBitmap; private AssetManager mAssetMan = null; private String[] mImgFileNames = null; private int mBitmapWidth; private int mBitmapHeight; @Override Protected Void doInBackground(Void... params){ mAssetMan = getAssets(); Log.e(TAG, "pressedStart"); try { mImgFileNames = mAssetMan.list("my_subfolder"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Log.d(TAG, "mImgFileNames = " + mImgFileNames); Log.d(TAG, "number of image files = " + mImgFileNames.length); for (int i = 0; i &lt; mImgFileNames.length; i++) { Log.d(TAG, "image file name = " + mImgFileNames[i]); InputStream istr = null; try { istr = mAssetMan.open("my_subfolder/" + mImgFileNames[i]); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // load the photo Bitmap b = BitmapFactory.decodeStream(istr); mFaceBitmap = b.copy(Bitmap.Config.RGB_565, true); b.recycle(); mBitmapWidth = mFaceBitmap.getWidth(); mBitmapHeight = mFaceBitmap.getHeight(); Log.d(TAG, "mBitmapWidth = " + mBitmapWidth); Log.d(TAG, "mBitmapHeight = " + mBitmapHeight); Drawable drawable = new BitmapDrawable(getResources(), mFaceBitmap); publishProgress(drawable); SystemClock.sleep(5000); } } @Override Protected Void onProgressUpdate(Drawable... values){ super.onProgressUpdate(values); mIV.setImageDrawable(values[0]); mIV.invalidate(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload