Sunday, 29 September 2013

Android (View): Child position inside ListView depending on android version

Android (View): Child position inside ListView depending on android version

Im developing an android-app which handles a ListView with several
TextViews within it as childs.
The problem (already solved) came when I tried to get child from the
parent view by using getChildAt(pos) method.
I have tested my app in two devices with different android versions
installed, and I got the following conclusions:
In android 2.2.1 the parent view refers their childs by using the
following position-indexation:
Parent.
Child_A: position 2
Child_B: position 1
Child_C: position 0
In android 4.0.3 the parent view refers their childs by using the
following position-indexation:
Parent.
Child_A: position 0
Child_B: position 1
Child_C: position 2
So, I would like to know from which version it changed the child
indexation protocol in order to operate in one way or antoher depending on
the android version installed in the target device.
What I want to do is somthing like this:
if androidVersion >= X then
___Use new chlid-indexation protocol
else
___Use old child-indexation protocol
Thanks.

No comments:

Post a Comment