Viewpager+fragment Slide Menu Effect implementation steps

Source: Internet
Author: User

1. Reference Viewpager <android.support.v4.view.viewpager android:id= "@+id/viewpager" android:layou in XML T_width= "Fill_parent" android:layout_height= "wrap_content" android:layout_gravity= "center"/>
2, the code defines Viewpager and initializes the control private Viewpager Viewpager; Viewpager = (Viewpager) Findviewbyid (R.id.viewpager);
3, set the adapter to Viewpager (custom adapter, inherit from Fragmentpageradapter) Private mainpageradapter pageradapter = null;    Pageradapter = new Mainpageradapter (Getsupportfragmentmanager ()); Viewpager.setadapter (Pageradapter);
4. Implements Onpagechangelistener Viewpager.setonpagechangelistener (this), bound page Toggle Listener Event
5, if you want to click the switch effect, then in the Click event Update interface Subscript change index to the corresponding subscript value (starting from 0) Viewpager.setcurrentitem (index);

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Viewpager+fragment Slide Menu Effect implementation steps

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.