I agree, and I can adapt my code to use the selected item instead of the selected view...but it is worth noting that the consequence of this is that seemingly identical layouts can yield very different behavior. In this case, two layouts containing invisible items can return either a valid view or a null, which is both dangerous and somewhat arbitrary...not random of course, but slightly arbitrary. I'm just pointing that out, I'm not arguing against the optimization necessarily.
On Apr 21, 8:24 am, Mark Murphy <mmur...@commonsware.com> wrote: > On Thu, Apr 21, 2011 at 11:17 AM, Keith Wiley <kbwi...@gmail.com> wrote: > > I have determined the discrepancy. Your code calls getSelectedItem() > > on the spinner. Mine calls getSelectedTextView(). In your case, you > > get a non-null response regardless of the visible status. In mine, I > > get a null if it is initially gone, but I get a TextView if it is > > initially visible. Furthermore, if I toggle the spinner's visibility > > from gone to visible, I get a non-null response, AND if I toggle > > twice, thus hiding the spinner again, I still get a nonnull response. > > Right. If an AdapterView is hidden, it is not querying the Adapter for > any rows/cells/whatever, and so you'll get null for getSelectedView(). > This is a perfectly reasonable optimization, IMHO. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android 3.0 Programming Books:http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en