mercredi 25 février 2015

Android: Set an image to an ImageButton in a separate thread (background)


Vote count:

0




I am using a ViewPager and it's horizontal screen sliding feature to swipe between Fragments that each contain an image.


However, the pages are very slow to load since I am currently loading these images on the UI Thread. Here's how I am currently doing it:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pictures);

imageButton.setImageResource(R.drawable.picture_one);
}


I'd like to simply load my image (R.drawable.picture_one) to the ImageButton on a background/separate thread.


I looked at Cursor, but it seems to only be used for database queries.


How would I do this? Thank you!



asked 54 secs ago







Android: Set an image to an ImageButton in a separate thread (background)

Aucun commentaire:

Enregistrer un commentaire