CopyPastor

Detecting plagiarism made easy.

Score: 2; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2022-12-08
by Aniruddh Parihar

Original Post

Original - Posted on 2012-11-18
by Rajul



            
Present in both answers; Present only in the new answer; Present only in the old answer;

The more general extension of `ViewPager` would be to create a `SetPagingEnabled` method so that we can enable and disable paging on the fly. To enable / disable the swiping, just overide two methods: `onTouchEvent` and `onInterceptTouchEvent`. Both will return "false" if the paging was disabled.
public class CustomViewPager extends ViewPager {
private boolean enabled;
public CustomViewPager(Context context, AttributeSet attrs) { super(context, attrs); this.enabled = true; }
@Override public boolean onTouchEvent(MotionEvent event) { if (this.enabled) { return super.onTouchEvent(event); } return false; }
@Override public boolean onInterceptTouchEvent(MotionEvent event) { if (this.enabled) { return super.onInterceptTouchEvent(event); } return false; } public void setPagingEnabled(boolean enabled) { this.enabled = enabled; } }
Then select this instead of the built-in viewpager in XML
<mypackage.CustomViewPager android:id="@+id/myViewPager" android:layout_height="match_parent" android:layout_width="match_parent" />
You just need to call the `setPagingEnabled` method with `false` and users won't be able to swipe to paginate.
The more general extension of `ViewPager` would be to create a `SetPagingEnabled` method so that we can enable and disable paging on the fly. To enable / disable the swiping, just overide two methods: `onTouchEvent` and `onInterceptTouchEvent`. Both will return "false" if the paging was disabled.
public class CustomViewPager extends ViewPager {
private boolean enabled;
public CustomViewPager(Context context, AttributeSet attrs) { super(context, attrs); this.enabled = true; }
@Override public boolean onTouchEvent(MotionEvent event) { if (this.enabled) { return super.onTouchEvent(event); } return false; }
@Override public boolean onInterceptTouchEvent(MotionEvent event) { if (this.enabled) { return super.onInterceptTouchEvent(event); } return false; } public void setPagingEnabled(boolean enabled) { this.enabled = enabled; } }
Then select this instead of the built-in viewpager in XML
<mypackage.CustomViewPager android:id="@+id/myViewPager" android:layout_height="match_parent" android:layout_width="match_parent" />
You just need to call the `setPagingEnabled` method with `false` and users won't be able to swipe to paginate.

        
Present in both answers; Present only in the new answer; Present only in the old answer;