Use of the Android:viewpager adapter Pageradapter

Source: Internet
Author: User

PageAdapter is an abstract class that inherits directly from object and is imported into the package Android.support.v4.view.PagerAdapter to be used.

To use Pageradapter,

The first step is to inherit the Pageradapter class, overwriting at least the following methods:

The following four methods are called each time a viewpager or swipe is created, and the methods in Instantiateitem and Destroyitem are implemented on their own.

public abstract int GetCount ();

This method is to get the current form interface number

Public abstract Boolean Isviewfromobject (Android.view.View arg0, Java.lang.Object arg1);

This method is used to determine whether the interface is generated by the object

 Public int position);

This method, return an object that indicates which object the Pageradapter adapter chooses to place in the current Viewpager

 Public void int position, java.lang.Object Object);

This method is to remove the current view from the ViewGroup

 Public classViewpageradapterextendspageradapter{@Override Public intGetCount () {//TODO auto-generated Method Stub            return0; } @Override Public BooleanIsviewfromobject (View arg0, Object arg1) {//TODO auto-generated Method Stub            return false; } @Override Public voidDestroyitem (View container,intposition, Object object) {            //TODO auto-generated Method Stub            Super. Destroyitem (container, Position, object); } @Override PublicObject Instantiateitem (View container,intposition) {            //TODO auto-generated Method Stub            return Super. Instantiateitem (container, position); }            }

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.