Hi, I actually have a ViewHolder in my adapter class, and in it, I have an int position. How do I access it when I select a list item either by clicking on the radio button or by tapping directly on the list item?
Thanks! On Monday, October 14, 2013 10:27:00 PM UTC+8, Piren wrote: > > You're not really supposed to use the Views/ListView for such information, > rather the Adapter (ListViews recycle views, the amount of children they > have fits the amount items they can fit in the screen, not the amount of > items in the backing store). > You can however still use the views if you also store the appropriate > index in the view during onBind... it gets easier if you use the ViewHolder > pattern since the ViewHolder object makes it easy to also store extra > information (like that index you want). > > On Monday, October 14, 2013 8:42:09 AM UTC+3, galapogos wrote: >> >> Hi, >> >> I have a list that is multiple pages long, and I'm trying to get the list >> index of the item that is selected using radio buttons. In >> onClickRadioButton() which I'm passing in my current View, I'm setting the >> myview as view.getParent() and the list index as ((ViewGroup) >> myview.getParent()).indexOfChild(myview). >> >> The listindex is correct (starts from 0) when the list is 1 page long, >> but whenever I scroll down a list that's longer than a page, the list >> index gets reset to 0 based on the item that's on the top of the page. Does >> anyone know what I'm doing wrong? Does is have anything to do with my View >> and getParent()? >> >> Thanks! >> > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

