android - Fragment content not loading on BottomNavigationView FragmentTransaction -




i have application uses bottomnavigationview navigate between fragments. 1 of fragments (searchfragment) has tab view, implemented easytabs.

when navigate searchfragment first time, layout loads correctly, 3 tabs populated. problem when navigate fragment , return searchfragment, layout doesn't load. tab view in top of screen, content not shown, in way need navigate between tabs make them appear 1 one.

onnavigationitemselected method:

@override public boolean onnavigationitemselected(@nonnull menuitem item) {     switch (item.getitemid()) {         case r.id.tab_search:             mfragment = new searchfragment();             break;                 /*case r.id.tab_history:                     mfragment = new radiofragment();                     break;*/         case r.id.tab_desc:             bundle bundle = new bundle();             bundle.putboolean("fromsetup", false);             mfragment = new descriptionfragment();             mfragment.setarguments(bundle);             break;                 /*case r.id.tab_config:                     mfragment = new radiofragment();                     break;*/     }     final fragmenttransaction transaction = mfragmentmanager.begintransaction();     transaction.replace(r.id.main_container, mfragment).addtobackstack(null).commit();     return true; } 

easytabsbuilder inside searchfragment:

easytabsbuilder.with(mtabs)             .addtabs(                     new tabitem(new searchbydatefragment(), ""),                     new tabitem(new searchbyeventfragment(), ""),                     new tabitem(new searchbydescriptionfragment(), "")             )             .settabsbackgroundcolor(easytabscolors.white)             .setindicatorcolor(easytabscolors.gray)             .settextcolors(easytabscolors.black, easytabscolors.white)             .addicons(                     r.drawable.ic_date_range_black_24dp,                     r.drawable.ic_face_black_24dp,                     r.drawable.ic_description_24px)             .hidealltitles(true)             .build(); 

i got same issue bottom navigation , tab layout.

the solution found remove search fragment , 3 tab fragment manager. can in onpageselected pagechangelistener

example

        @override         public void onpageselected(int position) {             if (position != 3 && position != 2) {                 list<fragment> fragments = getsupportfragmentmanager().getfragments();                 (int = fragments.size() -1; >= 0; i--) {                     if (fragments.get(i) != null) {                         if (fragments.get(i).getclass() == orderinprogressfragment.class ||                                 fragments.get(i).getclass() == orderfinishfragment.class ||                                 fragments.get(i).getclass() == orderfragment.class) {                             getsupportfragmentmanager().begintransaction().remove(fragments.get(i)).commit();                             getsupportfragmentmanager().executependingtransactions();                         }                     }                 }             }              bottomnavigationview.getmenu().getitem(position).setchecked(true);         } 

i got 4 page on bottomnavigation , fragment remove in 3 position. if check if using fragment or if on previous tab, if not remove orderfragment contains tab , 2 other tab inside it





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -