How To Set Imageview Using Bitmap Array
Solution 1:
Its so simple way use setImageBitmap..
imageView.setImageBitmap(imageAdapter.bm[position]);
Solution 2:
You should use , setImageBitmap (Bitmap bm) method which Sets a Bitmap as the content of this ImageView.
So your code will be,
imageView.setImageBitmap(imageAdapter.bm[position]);
Solution 3:
imageView.setImageBitmap(imageAdapter.bm[position]);
Solution 4:
here i give you my code of my app that works with a gallery from drawable resources with int position, modify it for your needs, should work with your code.
My intent of gallery is:
@OverridepublicvoidonItemClick(AdapterView<?> parent, View view, int position, long id) {
intselectedId= imgs[position];
Intentintent=newIntent(Gallery3DActivity.this,MainActivity.class);
intent.putExtra("imageId", selectedId);
startActivity(intent);
}
In the main activity i receive the intent and set it on the imageview:
Intentavatar= getIntent();
intimageId= avatar.getIntExtra("imageId", -0);
// -0 would be a default value// -1 will crash with a missing resourceif (getIntent().getExtras() != null) {
Avatar.setImageResource(imageId);
savedAvatar.setImageResource(imageId);
} else {
Avatar.setImageResource(R.mipmap.ic_launcher);
}
Your code is similiar as mine, but you get it from url them to bitmap, me i get it from drawable resources, with long id list set on the activity java for name and position, i chose the one i want to set as avatar them pass it inside intent to main activity and define the intent name that contains the drawable cache to an imageview, after in button onclick i convert to bitmap, bitmap to string, string to image to restore imageview view on start main activity, and i save the string to sharedpreferences, getting the imageview view back again even after close the app.
Good luck
Post a Comment for "How To Set Imageview Using Bitmap Array"