Android Viewpager + fragment check current fragment to trigger some things again.

Source: Internet
Author: User

A problem has been encountered in the recent project:

Background: Use Viewpager+fragment to make the first page slide, then need to automatically pop up the dialog box when the third fragment is selected.

Workaround:

1, in

Vp.setonpagechangelistener (New Onpagechangelistener ()        {                        @Override public            void onpageselected (int arg0)            {                //arg0 is the location of the current fragment, you can handle some business.            }
}
2, Frgment provides a method

@Override public    void Setuservisiblehint (Boolean isvisibletouser)    {        logutil.i ("TAG", " Setuservisiblehint ("+ Isvisibletouser +") ");        To a display state of true, not visible as false        if (Isvisibletouser)        {                  }        super.setuservisiblehint (Isvisibletouser);    }
3, Viewpager inside the View list, and then when no view is selected, bind the corresponding fragment.



Android Viewpager + fragment check current fragment to trigger some things again.

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.