To inherit the PagerAdapter class, you need to override the five methods and the Click Event method summary of ViewPager. pageradapter
To inherit the PagerAdapter class, you must override five methods:
Public int getCount (){
Return pages. size ();
}
Returns the page length.
Public boolean isViewFromObject (View arg0, Object arg1 ){
Return arg0 = arg1;
}
Determine whether the pager object to be loaded returned by instantiateItem (ViewGroup container, int position) is a view. If yes, true is returned and displayed. If no value is returned, false is not displayed.
Public CharSequence getPageTitle (int position ){
Return super. getPageTitle (position );
}
Obtain the text to be displayed in the tab area of the corresponding position.
Public void destroyItem (ViewGroup container, int position, Object object Object ){
Container. removeView (pages. get (position ));
}
Destroys three additional pager objects.
Container vp object
Position vp object subscript
Public Object instantiateItem (ViewGroup container, int position ){
Container. addView (pages. get (position ));
Return pages. get (position );
}
How to load pager,
Container: The ViewPager object used to load the page.
Position: subscript for Each pager during the filling process
The returned object is the pager object currently filled in.
Method of ViewPager Click Event: setOnPageChangeListener ();
Public void onPageScrollStateChanged (int arg0 ){}
Called when the page sliding status changes. arg0 is the position of the pager currently displayed.
Public void onPageScrolled (int arg0, float arg1, int arg2 ){}
Called when the page slides up. Arg0 indicates the position of the pager currently displayed, arg1 indicates the sliding percentage, and arg2 indicates the position after sliding.
Public void onPageSelected (int arg0 ){}
Event method after sliding, arg0 is the position after sliding