List view items changes position when scrolling android?

前端 未结 4 1833
花落未央
花落未央 2020-11-27 15:31

In my application i used custom list view adapter. In the list view item i added another layout. because in my service one order have any number of order items. For showing

相关标签:
4条回答
  • 2020-11-27 15:55

    you are using two arrays - "bpData" and "opData" and you only reset if under specific conditions with "opData".

    This is a bad design. You need one array - if "opData" is dependent on "bpData" then make it a variable of "bpData".

    Or else write something to synchronize the two. Otherwise, you do not know how the display will work.

    0 讨论(0)
  • 2020-11-27 15:56

    I had the same issue then below link resolved my problem ;

    https://stackoverflow.com/a/36738935/3341089

    Basically, you should specify your item types then reconfigure your adapter via getItemViewType(int position) and getViewTypeCount() override methods.

    If you look into above link, you will get it.

    0 讨论(0)
  • 2020-11-27 16:02

    In your adapter class override these two methods

    @Override
      public int getViewTypeCount() {
    
       return getCount();
      }
    
      @Override
      public int getItemViewType(int position) {
    
       return position;
      }
    
    0 讨论(0)
  • 2020-11-27 16:14
    @Override
      public int getViewTypeCount() {
    
       return getCount();
      }
    
      @Override
      public int getItemViewType(int position) {
    
       return position;
      }
    

    Works proper for me

    0 讨论(0)
提交回复
热议问题