question

njsokalski avatar image
0 Votes"
njsokalski asked RobCaplan edited

RecyclerView: GetChildAdapterPosition vs IndexOfChild vs GetChildLayoutPosition

I have been doing a lot of work with RecyclerView, and because of the recycling feature, indexes & positions are sometimes confusing. Three methods I am aware of are:
GetChildAdapterPosition
IndexOfChild
GetChildLayoutPosition
Are there any good sites that give a comparison / explanation of these methods?

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JessieZhang-2116 avatar image
0 Votes"
JessieZhang-2116 answered

Hello,


Welcome to our Microsoft Q&A platform!

For this, you can check offcial document RecyclerView.

From this document ,we know:

  1. method getChildAdapterPosition ;

     int getChildAdapterPosition (View child)
    

    Return the adapter position that the given child view corresponds to.

  2. method getChildLayoutPosition;

         int getChildLayoutPosition (View child)
    

    Return the adapter position of the given child view as of the latest completed layout pass.

    This position may not be equal to Item's adapter position if there are pending changes in the adapter which have not been reflected to the layout yet.

For more about this, you can check document: https://developer.android.com/reference/android/support/v7/widget/RecyclerView .

Best Regards,

Jessie Zhang


If the response is helpful, please click "Accept Answer" and upvote it.


Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.