To inherit the PagerAdapter class, you need to override the five methods and the Click Event method summary of ViewPager. pageradapter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.