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