Skip to content Skip to sidebar Skip to footer

How To Take A Selected Image From Gallery Widget And Show In Another Activity?

I am trying to load a selected image from Gallery Widget and load it in another activity, I will really appreciate help! Basically it is about take the image that I select in the G

Solution 1:

Well, looks like you can get the resource ID of the selected image by doing the following:

@OverridepublicvoidonItemClick(AdapterView parent, View v, int position, long id) {
    intselectedId= images[position];  
}

You could pass that selected resource id to another Activity like this:

Intent intent = newIntent(Vehiculos.this, OtherActivity.class);
intent.putExtra("imageId", selectedId);
startActivity(intent);

And then retrieve the id in your other Activity like this:

Intentintent= getIntent();
intimageId= intent.getIntExtra("imageId", -1); // -1 would be a default value

This is a rough example - you will probably need to add some error-checking.

Post a Comment for "How To Take A Selected Image From Gallery Widget And Show In Another Activity?"