Home > Mobile >  Adapter space and asynchronous data binding
Adapter space and asynchronous data binding

Time:11-23

Recycleview textview, textview value through the adapter onbindviewholder okhttp asynchronous method to obtain, but there will be disorder, avatars and username inconsistent problems,
(blind guess may control no binding, assigned to the other textview)
How to solve

CodePudding user response:

This is generally get to reproduce the data into the list first

CodePudding user response:

Reason:
Control reuse, because it is asynchronous operations, leading to a network request textView set after the completion of the content is updated, asynchronous without order, easily disorder,
Solution:
. Pass in the adapter textView setTag (position), tag set the current position, in the network request is completed, again through the int currentPosition=(int) textView. GetTag (), to determine whether the position is equal to the currentPosition, if equal setText (" XXXX "), or reuse description this position by other items, at this time is no longer display, assignment can no longer,

CodePudding user response:

reference 1st floor ink_s response:
this is generally get to reproduce the data into the list first

Right, but I need is, at the time of rendering, and populate the request data

CodePudding user response:

refer to the second floor of blue sky ywj reply:
:
Control reuse, because it is asynchronous operations, leading to a network request textView set after the completion of the content is updated, asynchronous without order, easily disorder,
Solution:
In the adapter first through textView. SetTag (position), tag set the current position, in the network request is completed, again through the int currentPosition=(int) textView. GetTag (), to determine whether the position is equal to the currentPosition, if equal setText (" XXXX "), or reuse description this position by other items, at this time is no longer display, no longer assignment,

I know this principle, but because to display the user name, so can't show, and want everyone to display correctly

CodePudding user response:

Don't display, if be reuse, illustrate the viewitem is no longer visible, so don't show; At the same time it will be displayed viewitem assignment

CodePudding user response:

Add a UPDATA method, okhttp get values to a list, and then refresh the list

Public void upData (ArrayList Data) {
This. Flies=data;
NotifyDataSetChanged ();
}

CodePudding user response:

No, still not correct, I use hanlder reception, the tag does not correspond to, is not the assignment,
  • Related