Why in the world are you casting the result of getItemAtPosition to View?

5 января 2012 г. 23:46 пользователь John Davis <[email protected]> написал:

> Hello Mark,
>
> Nope.
>             for (int i=0;i<numRows;i++) {
>                 // If it is the 2nd or 5th item, tag it so that it will be
> displayed in blue.
>                if (i==2 || i==5) {
>                        listCount = adapter.getCount();
>                        count = theList.getCount();
>                        fooView = (View) theList.getItemAtPosition(i);
> //                      fooView.setTag(99);
>                }
>
> i=2, listCount = 6 and count = 6.  The listview stored in theList is
> functional, since it retuns the result provided by getCount.  It is
> also in agreement with the array adapter count.
> theList.getItemAtPositon(5) should either return the item or null.  It
> raises and exception.  That is a bug.
>
> Once again, the docs say:
> =========================
> public Object getItemAtPosition (int position)
>
> Since: API Level 1
> Gets the data associated with the specified position in the list.
> Parameters
>
> position        Which data to get
> Returns
>
> The data associated with the specified position in the list
>
> ===============
>
> On Thu, Jan 5, 2012 at 2:31 PM, Mark Murphy <[email protected]>
> wrote:
> > 2012/1/5 John Davis <[email protected]>:
> >> The only exception which i can find is
> javalang.unsupportedOperationException.
> >> as I was saying the api has a bug. The docs say you can get the data,
> >> when you try to so you get an exception. Either the docs are incorrect
> >> or its a bug.
> >
> > Yes, it is a bug in your code. My guess is that you are asking for an
> > invalid position, perhaps because numRows is greater than getCount().
> >
> > --
> > Mark Murphy (a Commons Guy)
> > http://commonsware.com | http://github.com/commonsguy
> > http://commonsware.com/blog | http://twitter.com/commonsguy
> >
> > Warescription: Three Android Books, Plus Updates, One Low Price!
> >
> > --
> > 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
>
>
>
> --
> John F. Davis
>
> 独树一帜
>
> --
> 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
>

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