Activity nesting level fragment, level fragment nesting level two fragment, refresh UI in level two fragment in level fragment

Source: Internet
Author: User

Today encountered a very tangled problem, due to product design problems, technology involved in the activity nesting level fragment, a level fragment nested level two fragment, in the first level fragment refresh the UI in level two fragment.

The first level fragment has the top search bar, the search bar below the viewpager+fragment layout, the search bar to update the child's current page fragment search method, and refresh the UI.

Adapter

Private classOrdermanagerfragmentpageradapterextendsFragmentpageradapter { PublicOrdermanagerfragmentpageradapter (fragmentmanager FM) {Super(FM); } @Override PublicFragment GetItem (intposition) {            Switch(position) { Case0:                    returnneworderfragment.newinstance ();  Case1:                    returnfollowingfragment.newinstance ();  Case2:                    returndesperatelyfollowingfragment.newinstance ();  Case3:                    returnrobbedfragment.newinstance ();  Case4:                    returntransferfragment.newinstance ();  Case5:                    returnclinchdealfragment.newinstance ();  Case6:                    returnlostfragment.newinstance ();  Case7:                    returnnoeffectfragment.newinstance (); default:                    return NULL; }} @Override PublicCharsequence Getpagetitle (intposition) {            returnTitles[position%Titles.length]; } @Override Public intGetCount () {returntitles.length; }    }

Call adapter's GetItem () and invoke the fragment search method of the child's current page, and refresh the UI, but error, the UI component in the child fragment is null,adapter null;

The correct call posture is:

int    Position   = Pager.getcurrentitem ();         = Searchtv.getsearchword ();         // two layer fragment nested, call the specified fragment refresh operation, Fuck, this method was found for several days       Fragment Fragment = Getchildfragmentmanager (). Getfragments (). get (position);

Gets the currently displayed child fragment, then invokes the search method of the child fragment and refreshes the UI., perfect realization.

Activity nesting level fragment, level fragment nesting level two fragment, refresh UI in level two fragment in level fragment

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.