Hi

I actually didn't answer you to give you the answer but to make you
move :D
I've read on you stackoverflow post that you were frustrated for 2
days over that two lines of code problem.
That is severe procrastination if you ask me :D

My take on this is simple :

If I need more than 30 minutes to find a solution to a problem that I
know how to solve in 10 minutes in a ugly-but-productive fashion, then
I switch to my solution.

Once my project is released and if it is successfull enough for me to
continue working on it then I will always be able to do some
refactoring if I ever find a better solution.

Beside, and it's a very personnal mindset, but the idea that you can
pass different type of variables to a function to make it do the same
thing does really not make it a good, readable, scalable, and easy to
maintain code.
When I write my code I always tend to have a "Different parameters,
different method" rule.

Again all of this is very personal and I think we fall in the
"whatever works for you" zone here :D

I'm not very good at english either so we're even :)

Good luck on your project.

Yahel




On 24 fév, 21:56, 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

-- 
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