Fragment instantiate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Fragment instantiate method.

This code example shows how to use the following methods: getAdapter, getCurrentItem, setCurrentItem
 
    /** 
     * Hack to enable reloading fragments while they are being viewed 
     */ 
    public void forceReload() { 
        int position = getCurrentItem();
        setAdapter(getAdapter()); 
        setCurrentItem(position, false);
    } 
 
    /** 
     * Show the supplied filter, adding it to the data source if it doesn't exist 
     * @param f 
     */ 
    public void showFilter(Filter f) { 
        TaskListFragmentPagerAdapter adapter = (TaskListFragmentPagerAdapter) getAdapter();
        showFilter(adapter.addOrLookup(f));
    } 
 
    /** 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
import android.view.MotionEvent; 
 
public class NestableViewPager extends ViewPager { 
 
    public NestableViewPager(Context context, AttributeSet attrs) { 
        super(context, attrs); 
    } 
 
    /** 
     * Prevent horizontal scrolling 
     */ 
     @Override 
    public boolean onInterceptTouchEvent(MotionEvent event) { 
         return false; 
    } 
 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAdapter, getCurrentItem, onTouchEvent, getParent
    public boolean onTouchEvent(MotionEvent event) {
        final int action = event.getAction();
        if (action == MotionEvent.ACTION_DOWN) {
            //mCurrX = event.getX(); 
        } else if (action == MotionEvent.ACTION_MOVE) {
            if (getCurrentItem() == 0 && ((event.getX() - mCurrX) > mTouchSlop)) {
                // User moved finger to the right and is on the leftmost ViewGroup 
                getParent().requestDisallowInterceptTouchEvent(false); 
            } else if (getCurrentItem() == (getAdapter().getCount() - 1) && ((mCurrX - event.getX()) > mTouchSlop)) {
                // User moved finger to the left and is on the rightmost ViewGroup 
                getParent().requestDisallowInterceptTouchEvent(false); 
            } else if (Math.abs(event.getY() - mCurrY) > Math.abs(event.getX() - mCurrX)) {
                // User scrolled vertically 
                getParent().requestDisallowInterceptTouchEvent(false); 
            } 
        } 
        return super.onTouchEvent(event);
    } 
} 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getChildAt, getMeasuredWidth, onMeasure, setMeasuredDimension
      super(context, attrs);
   } 
 
   @Override 
   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
      // find the first child view 
      View view = getChildAt(0);
      if (view != null) {
         // measure the first child view with the specified measure spec 
         view.measure(widthMeasureSpec, heightMeasureSpec);
      } 
 
      setMeasuredDimension(getMeasuredWidth(), measureHeight(heightMeasureSpec, view));
   } 
 
   /** 
    * Determines the height of this view 
    *  
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 * @author Chris Banes 
 */ 
public class HackyViewPager extends ViewPager { 
 
    public HackyViewPager(Context context) {
        super(context);
    } 
 
    public HackyViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    } 
 
    @Override 
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        try { 
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return false; 
        } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Fragment instantiate Questions & Answers:

instantiate Method Overview
Like instantiate(Context, String, Bundle) but with a null argument Bundle.
See Code Examples for other Android Fragment Methods: