Android add fragments to end of FragmentStatePagerAdapter -
i want adapter add page each time reaches last page. here code tried using:
static int items = 2; public static class myadapter extends fragmentstatepageradapter implements onpagechangelistener{ public myadapter(fragmentmanager fragmentmanager) { super(fragmentmanager); } @override public int getcount() { return items; } @override public fragment getitem(int position) { if (position >= items-1) { items++; notifydatasetchanged(); } fragment f = reviewfragment.init(position); return f; }
i suggest this:
public static class myadapter extends fragmentstatepageradapter implements onpagechangelistener{ public myadapter(fragmentmanager fragmentmanager) { super(fragmentmanager); } @override public int getcount() { return integer.max_value;; } @override public fragment getitem(int position) { fragment f = reviewfragment.init(position); return f; } }
Comments
Post a Comment