android - No view found for ID xxx for fragment (nested fragments) -


i have activity has viewpager in layout.

i have 2 fragments display, 1 each tab.

one of fragments designed host other fragments - customermainfragment inflates fragment_customer_main:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/lyt_customer_main"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >      <framelayout         android:id="@+id/fragment_customer_content"         android:layout_width="fill_parent"         android:layout_height="fill_parent" />  </linearlayout> 

this adds customersearchfragment framelayout inflates fragment_customer_search.

customersearchfragment has following override switch out search fragment detail fragment on button press:

@override public void onviewcreated(view view, bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);      button btnsearch1 = (button) view.findviewbyid(r.id.button1);     if (btnsearch1 != null) {         btnsearch1.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                 // important bit                 fragment customerdetailfragment = new customerdetailfragment();                 fragmenttransaction transaction = getchildfragmentmanager().begintransaction();                 transaction.addtobackstack(null);                 transaction.replace(r.id.fragment_customer_content, customerdetailfragment).commit();              }         });     } } 

after clicking button following error:

java.lang.illegalargumentexception: no view found id 0x7f080006 (com.chrisbeckyapps.sample:id/fragment_customer_content) fragment customerdetailfragment{4280b0b8 #0 id=0x7f080006}

i'm new fragments , understand concepts, i'm stumped this. had search fragment going straight pager, replacing detail fragment mean showed on top, , research led being better solution.

i have wondered trying move search logic customermainfragment means hooking lot of logic , thought embed logic within fragments.

suggestions?

sorry, found such simple fix.

in onclick handler, had change getchildfragmentmanager getfragmentmanager


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -