Android : Referencing child fragment from parent fragment -


i have nested fragment scenario. attempts reference child fragment parent fragment gives null. missing here?

this layout file of parent fragment.

   <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="vertical">      <!-- statically nested fragment -->     <fragment         android:name="reports.fragments.fragments.usagebreakup.fragments.filter"         android:id="@+id/fragment_filter"         android:layout_width="match_parent"         android:layout_height="wrap_content"/>  </linearlayout> 

here how trying access child fragment parent fragment

@override public void onviewcreated(view view, @nullable bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);     log.i(log_tag, "on view created");      filter = (filter) getchildfragmentmanager().findfragmentbyid(r.id.fragment_filter);     filter.populatestoragefilter(); // npe here } 

have tried

filter = (filter) view.findviewbyid(r.id.fragment_filter); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -