android - Remove a fragment of a specific index from a view pager -



android - Remove a fragment of a specific index from a view pager -

im trying remove fragment specific index. happening viewpager , pageradapter hiding lastly fragment.

this code:

public class sectionspageradapter extends fragmentstatepageradapter { arraylist<string> data_fragment; public sectionspageradapter(fragmentmanager fm) { super(fm); data_fragment = new arraylist<>(); data_fragment.add(0, "página 0"); } public void addnewfragmentdata(string data) { // int last_position = data_fragment.size(); data_fragment.add(data); notifydatasetchanged(); } public void removefragmentdata(int index) { // destroyitem(container, position, object); data_fragment.remove(index); notifydatasetchanged(); } @override public int getitemposition(object object) { homecoming position_none; } // @override // public void destroyitem(viewgroup container, int position, object object) // { // data_fragment.remove(position); // super.destroyitem(container, position, object); // } @override public fragment getitem(int position) { log.i("paginas", "getitem"); homecoming lienzofragment.newinstance(position); } @override public int getcount() { homecoming data_fragment.size(); } @override public charsequence getpagetitle(int position) { homecoming data_fragment.get(position); } }

as see, i'm trying avoid retain fragment object. approach maintain title , each fragment manage own save/restore state itself.

int tab_selected = mviewpager.getcurrentitem(); msectionspageradapter.removefragmentdata(tab_selected); //msectionspageradapter.destroyitem(mviewpager, tab_selected, mviewpager.getchildat(tab_selected)); mviewpager.removeviewat(tab_selected); mviewpager.setcurrentitem(tab_selected-1, true);

android android-fragments android-viewpager

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -