android viewpager notifyDatachange return to first -


i'm working in android projet. use tab display data fragment. in third fragment, when update data, viewpager return first. try everything.

this viewpageradapter

public class viewpageradapter extends fragmentpageradapter {     private final list<fragment> mfragmentlist = new arraylist<>();     private final list<string> mfragmenttitlelist = new arraylist<>();     private int baseid=0;      public viewpageradapter(fragmentmanager manager) {         super(manager);     }      @override     public fragment getitem(int position) {         return mfragmentlist.get(position);     }      @override     public int getcount() {         return mfragmentlist.size();     }      public void addfragment(fragment fragment, string title) {         mfragmentlist.add(fragment);         mfragmenttitlelist.add(title);     }      @override     public charsequence getpagetitle(int position) {         return mfragmenttitlelist.get(position);     }      @override     public int getitemposition(object object) {         return pageradapter.position_none;     }       @override     public long getitemid(int position) {         // give id different position when position has been changed         return baseid + position;     }      /**      * notify position of fragment has been changed.      * create new id each position force recreation of fragment      * @param n number of items have been changed      */     public void notifychangeinposition(int n) {         // shift id returned getitemid outside range of previous fragments         baseid += getcount() + n;     } } 

thanks.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -