I am using this example: http://android-er.blogspot.com/2012/07/implement-gallery-like.html to implement a horizontalscrollview "gallery" except I am using imagebuttons instead of an imageview. I have 3 horizontalscrollview's on my screen, I want the user to be able to select an image from each scrollview and when a button is pressed to send the selected images to a new activity. If anything I really want to know how to get the selected images from each scroll view to a new activity. How to realize what the user has selected and get it in another activity? I am new the android development.
Implement an onClick Listener on the View you are adding in the method called "insertPhoto". And also set the Tag of the View as it's File Path.
So when the view is clicked, you will know which view is clicked and you can checked the Tag of the view from here to get the File Path.
EDIT :
View insertPhoto(String path){
Bitmap bm = decodeSampledBitmapFromUri(path, 220, 220);
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setLayoutParams(new LayoutParams(250, 250));
layout.setGravity(Gravity.CENTER);
ImageView imageView = new ImageView(getApplicationContext());
imageView.setLayoutParams(new LayoutParams(220, 220));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageBitmap(bm);
layout.addView(imageView);
layout.setTag(path);
layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String filePath = (String) v.getTag();
}
});
return layout;
}
/**
* Starts YourActivity Activity.
*
* @param context Activity Context.
* @param filePath URI of the File to be uploaded.
*/
public static void startPrinterActivity(Context context, String filePath) {
Intent intent = new Intent(context, YourActivity.class);
intent.putExtra("file_path", filePath);
context.startActivity(intent);
}