I kind of confussed and hope one of you nice people will help me.
I have written a app, and I have pictures which are stored in the /
drawable directory. My app makes a sliding gallery across the top,
(id gallery1) and as you select the picture in the gallery it load the
picture bigger underneath, (id image1). These a layed out in a XML
file. What I would like to do is be able to is when the image1 is
pressed it gives the option to save the picture on the SD Card.
My Whole Code is:
*********************************************************************************************
public class PicViews extends Activity
{
//---the images to display---
Integer[] imageIDs = {
R.drawable.pic01,
R.drawable.pic02,
R.drawable.pic03,
R.drawable.pic04,
R.drawable.pic05
};
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.displayview);
Gallery gallery = (Gallery) findViewById(R.id.gallery1);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent,
View v, int position, long id)
{
//---display the images selected---
ImageView imageView = (ImageView)
findViewById(R.id.image1);
imageView.setImageResource(imageIDs[position]);
}
});
}
public class ImageAdapter extends BaseAdapter
{
private Context context;
private int itemBackground;
public ImageAdapter(Context c)
{
context = c;
//---setting the style---
TypedArray a =
obtainStyledAttributes(R.styleable.Gallery1);
itemBackground = a.getResourceId(
R.styleable.Gallery1_android_galleryItemBackground,
0);
a.recycle();
}
//---returns the number of images---
public int getCount() {
return imageIDs.length;
}
//---returns the ID of an item---
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
//---returns an ImageView view---
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView imageView = new ImageView(context);
imageView.setImageResource(imageIDs[position]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new Gallery.LayoutParams(150,
120));
imageView.setBackgroundResource(itemBackground);
return imageView;
}
}
}
*********************************************************************************************
The Section of code which pulls up the image and makes the bigger
picture show is:
*********************************************************************************************
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent,
View v, int position, long id)
{
//---display the images selected---
ImageView imageView = (ImageView)
findViewById(R.id.image1);
imageView.setImageResource(imageIDs[position]);
}
});
**********************************************************************************************
Its at this point I want to be able to have a option to save the
picture either by pressing a button or ideally pressing the picture
which will bring up options.
Also what alterations in the manifest do I need to make to be able to
access the SD Card Storage?
Please help, I'm only learning.
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en