Code example for FragmentStatePagerAdapter

Methods: notifyDataSetChanged

0
        args.putString("buffer", buffer);
        newFragment.setArguments(args);
        buffers.add(newFragment);
        pager.setCurrentItem(buffers.size());
         
        notifyDataSetChanged(); 
    } 
 
    public BufferFragment getCurrentBuffer() { 
        int pos = pager.getCurrentItem();
         
        if (bufferListFragment == null) {
            // Tablet view 
            if (pos>=0 && pos < buffers.size()) {
                return buffers.get(pos);
            } 
        } else { 
            // Phone view 
            if (pos>=1 && pos <= buffers.size()) { 
                return buffers.get(pos-1);
            }