On Thu, Mar 29, 2012 at 11:35:32AM -0700, Lew wrote:
> Spooky wrote:
> >
> > Kostya Vasilyev wrote:
> > > The issue is that you're trying to cast *the array* whereas you
> > > intent was probably to cast *each element of the array*.
> >
> > I was just trying to directly convert the List (in this case,
> "I was just trying ..." implies that the rules of Java should accommodate
> your programming instead of the other way around.
No, it doesn't. It implies (rather strongly) that I thought, based on
the portions of the Dev Guide that I'd read on this, that I knew what I
was doing. I was wrong. Get over it...I have.
> Java doesn't let you cast across type hierarchies. Thus, you cannot cast
> 'Camera.Size' to 'String', nor can you cast 'Camera.Size[]' to 'String[]'.
Nor did I try (nor WOULD I try to do something stupid like that). Go
back and READ my original post. I said that I hadn't even GOTTEN to any
Camera.Size stuff---so far, only one, and that WAS a String[]. Where,
from THAT, do you get that I'm assuming I can just cast (and thus
magically translate) Camera.Size to String[]? Answer: you don't.
> You might find the Java tutorials informative.
Again, read what I posted. How many Java books did I go through? I lost
count.
> > List<String>) to an array of strings (String[]). I hadn't gotten
> > as far as the other settings types yet---just preparing for them
> > when I get to them.
There...see, I said it again. I hadn't gotten being List<String> and
String[]. Read what you're replying to next time. :-)
> > > You could try this:
> > >
> > > for (Camera.Size size : cameraSizeList) {
> > > stringArray.add(size.toString());
> > > }
> > >
> > ... etc....I was hoping for a direct conversio for each List to each
> > respective array, but I'm starting to think that might not be ideal,
> > after all.
And just in case that was misunderstood, I was saying that I liked his
idea, and that I thought it would work for me.
> > > Or you could combine the arrays into one Object[] array. The adapter
> > > would then call toString on each Object inside the array.
> >
> > Again, multiple arrays, not one.
> >
> Again, he's just making suggestions. Again.
Yes...I know. But the above assumes (or at least, appears to assume)
that I'm handing one huge list of settings to the spinner, whereas I'm
planning to reuse one spinner with multiple sets of data. I haven't
tried that yet, and if it doesn't work, that'll be just another lesson
learned for me. So I was just clarifying what I had in mind.
> > > But if you do that, you won't be able to refer to objects in the
> > > array and know their types (which may be useful), unless you used
> > > "instanceof".
> >
> > I've already got that covered. :-) A simple switch() in onItemClicked
> > will determine which type of settings are in effect, and respond
> > accordingly.
>
> Switching on types is an antipattern in O-O programming. Polymorphism, will
> do that switch for you.
Did I say ANYTHING about switching based on variable types? No. I was
saying that I would use the switch to take actions based on what the DATA
was. In other words, if spinner item #2 is "Incandescent" then I know
that the spinner's current data set is White Balance settings.
Understand now? :-)
> > Either way, I can use the example you showed above, and I think that'll
> > work for me.
> >
> The wrapper approach is one way but I normally use the simple array-copy
> technique. Why are you so afraid of that loop?
You mean the loop that, in the quoted text that you just responded to, I
I said I liked the loop idea, and implied that I would probably just use
it? Hmmmm? Read *what I wrote*. If you're trying to read my MIND,
instead, you're doing an absolutely miserable job of it. Even my CATS
do better than that (actually, they do really well at it). :-)
> List<String> choices = new ArrayList<String>(sizes.size());
> for (Camera.Size size : sizes )
> {
> choices.add(size.toString());
> }
Looks like the example I already decided to use. :-)
Kostya answered my question with a perfectly useable solution, and I
thought, in my response, that I made my appreciation for that clear.
Apparently, I didn't make that as clear as I thought I did. Apologies,
Kostya, for not making my appreciation for your help clear.
I still have some reading to do, but Kostya put me on the right track,
which is exactly what I needed, and what I was looking for.
Later,
--jim
--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) | Tux (E Cat): DS B+Wd Y 6 Y L+++ W+ C++/C++ I+++
[email protected] | T++ A E H+ S V- F++ Q+++ P/P+ B++ PA+ PL SC---
< Running FreeBSD 7.0 > |
ICBM / Hurricane: | Tiggerbelle: DS W+S+Bts % 1.5 X L W C+++/C+
30.44406N 86.59909W | I+++ T A E++ H S++ V+++ Q+++ P B++ PA++ PL+ SC
Android Apps Listing at http://www.jstrack.org/barcodes.html
--
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