I am new to android and I want share my image with the according position in my image storage array. I used an viewpage adopter so when a user swipes to the left or to the right, the imageview changes. Now I want share this which is a set of imageview code.
package anil.card.christmas.christmascard;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import java.io.File;
import java.io.FileOutputStream;
class ChristmasAdopter extends PagerAdapter {
Context mContext;
LayoutInflater mLayoutInflater;
ImageView imageView;
int imagepostion;
private int[] mResources = {R.drawable.cs25, R.drawable.cs2,R.drawable.dx,R.drawable.prd, R.drawable.op,
R.drawable.ud, R.drawable.ok,R.drawable.cs3,R.drawable.mux,R.drawable.ch, R.drawable.cs5,R.drawable.anil,
R.drawable.cs6, R.drawable.cs7, R.drawable.pk, R.drawable.cs8, R.drawable.cs9,R.drawable.gk, R.drawable.cs10,
R.drawable.cs11, R.drawable.cs13, R.drawable.cs14, R.drawable.cs15, R.drawable.cs16, R.drawable.cs17, R.drawable.cs19, R.drawable.cs21, R.drawable.cs23, R.drawable.cs1, R.drawable.cs27, R.drawable.cs29, R.drawable.cs31, R.drawable.cs33,
R.drawable.cs35,R.drawable.newyear,R.drawable.ny,R.drawable.mn,R.drawable.hp,R.drawable.lifenew,
R.drawable.cat,R.drawable.dog,R.drawable.flower,R.drawable.ws,R.drawable.chars,
R.drawable.ship,R.drawable.bells,R.drawable.gift,R.drawable.dj};
public ChristmasAdopter(Context context) {
mContext = context;
mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return mResources.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((LinearLayout) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View itemView = mLayoutInflater.inflate(R.layout.pager_item, container, false);
imageView = (ImageView) itemView.findViewById(R.id.imageView);
imagepostion=position;
imageView.setImageResource(mResources[position]);
container.addView(itemView);
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((LinearLayout) object);
}
// here is share content please tell me how i can share image which is show in imageView
public void shareContent(){
Toast.makeText(mContext, ""+imagepostion, Toast.LENGTH_SHORT).show();
}
private Bitmap getBitmapFromView(View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable =view.getBackground();
if (bgDrawable!=null) {
bgDrawable.draw(canvas);
} else{
canvas.drawColor(Color.WHITE);
}
view.draw(canvas);
return returnedBitmap;
}
}
}