On Feb 24, 9:56 pm, qlimax <[email protected]> wrote:
> ok I took that way of the if statement before to set the image....
>
> however, I still can't understand why imgView.setImageURI doesn't work
> with apk drawable resources.
>
> the code would look much more simple & scalable if that worked... you
> don't agree?
>
> I was not really stuck, I knew about the option you told me, simply I
> prefer to search for a maintainable solutions before to start to write
> ala  blind
>
>  (I'm very sorry for my english)
>
> btw thank you for the support :)
>
> On 24 Feb, 17:46, Hekki <[email protected]> wrote:
>
>
>
> > Hi,
>
> > I'm sorry but I don't understand your problem nor why you get stuck
> > and frustrated over this.
>
> > You want to be able to be able to open an image from a resource :
> > ImageView.setImageResource(resId)
>
> > if it's from the sdcard :
> > ImageView.setImageDrawable("/sdcard/myimage.jpg")
>
> > I do that in my app, it works fine. A simple if statement to check if
> > I have a int or a string and I'm done.
>
> > If you want your code to be classy, you could also simply derive a new
> > class from imageView and add a setImageFromAnywhere function
>
> > //pseudo code
> > setImageFromAnywhere(Object myPhoto) {
> >    if (myPhoto is an int) && ((int)myPhoto is available in R.id)
> > setImageResource((int) myPhoto); return;
> >    if (myPhoto is a String) && ((string)myPhoto is a file that
> > exists)  setImageDrawable((string) myPhoto); return;
>
> > }
>
> > Oh and don't forget to add a way to get photos from Assets and Url if
> > you want to be thorough :)
> > And you are right, you shouldn't loose two days to come to a solution
> > like this :D
>
> > Good luck
>
> > Yahel
>
> > On 24 fév, 18:17, qlimax <[email protected]> wrote:
>
> > > I've tried to explain my situation 
> > > here:http://stackoverflow.com/questions/2307374/need-suggetsion-about-a-mi...
>
> > > and posed the same question 
> > > here:http://stackoverflow.com/questions/2313148/imageview-setimageuri-does...
>
> > > in short, I want to use Uri, to don't discriminate between images
> > > coming from the sd card or from the phone/apk...
>
> > > In addiction I'm thinking about a db with a product table with the
> > > following columns:
> > > int _id|string name|string imageUri
>
> > > can you understand what I mean?
>
> > > if you think that mine, is a wrong approach, pls let me know... I'm
> > > open to any suggestion
>
> > > qlimax
>
> > > On 24 Feb, 14:30, Hekki <[email protected]> wrote:
>
> > > > Is there a reason why you are not using 
> > > > :ImageView.setImageResource(resId)
>
> > > > In your example :imageView.setImageResource(R.drawable.image)
>
> > > > Yahel
>
> > > > On 24 fév, 15:23, qlimax <[email protected]> wrote:
>
> > > > > anyone?
>
> > > > > On 23 Feb, 18:47, qlimax <[email protected]> wrote:
>
> > > > > > I'm trying to do the following thing without success:
>
> > > > > >ImageViewimgView=(ImageView)findViewById(R.id.imgView);
> > > > > > Uri imgUri=Uri.parse("android.resource://
> > > > > > my.package.name/"+R.drawable.image);
> > > > > >imageView.setImageURI(imgUri)
>
> > > > > > I'm stuck, because theimageViewjust shows nothing...
>
> > > > > > how I can get an Uri (that I can use asImageViewsource) from a local
> > > > > > resource?
> > > > > > which kind of Uri are accepted for theImageView?
>
> > > > > > It would  be nice, if someone could help me.
>
> > > > > > IMHO, this topic lacks of documentation....
>
> > > > > > thank you.
> > > > > > regards


did you try (pseudocode):

is = ContentResolver.openInputStream(uri)
bm = BitmapFactory.decodeStream(is)
iv.setImageBitmap(bm)

pskink

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to