Reputation: 17
I have the following code:
Layout :
<ViewFlipper android:id="@+id/viewFlipper"
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<include layout="@layout/imagen3"/>
<include layout="@layout/imagen2"/>
Example layout imagen3 :
<ImageView
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fondo3"/>
Java :
Uri imageUri = Uri.parse("android.resource://" + getPackageName()
+ "/drawable/" + "preview");
I want to create ImageURI with the id of the imageview.
Upvotes: 0
Views: 52
Reputation: 17
The problem is not whether internal or external, because it works correctly with the internal images, the problem is I want to use the same code to a different drawable corresponding to each image
Upvotes: 0
Reputation: 79
I don't think that this is a good idea because drawable is in internal storage so another application do not have access to this memory.
First you could make a copy of your image to external storage
Or EVEN BETTER create Content Provider. This is the most correct and secure way in android to share content. Look here for example.
Upvotes: 2
Reputation: 4659
You can get the R index for it (so you can use it) by using it's ID. Like this:
Integer imageIs = getImageViewResource(R.id.preview)
The you can do more things with it, like change the image:
setImageViewResource(R.id.preview, newImage)
Why you would ever want to set that to a URI as a mystery...
Upvotes: 0