Reputation: 306
@Override
public void onClick(View v) {
try {
//Write fileObject tag = imageView.getTag();
//Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.c);
Bitmap bmp= BitmapFactory.decodeResource(getResources(),v.getResources().getResourceName((Integer)v.getTag()));
String filename = "bitmap.png";
FileOutputStream stream = getApplicationContext().openFileOutput(filename, Context.MODE_PRIVATE);
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
//Cleanup
stream.close();
bmp.recycle();
i want to add the image id from viewPager instead of the R.drawable.img1, any1 please any help? i have edited my question, instaed of getting image from drawable i need to get ithe current image on viewPager. how do i do it?
Upvotes: 1
Views: 1856
Reputation: 306
i have found the solution to this
Bitmap bmp=getBitmapFromView(viewPager.getChildAt(1));
i got my solution with this, thanks for all your feedbacks
Upvotes: 1
Reputation: 309
View Pager must be having an adapter. In getView method, set position as tag to the imageviews. Then for each positions , access the imageviews as per requirement.
Upvotes: 0