android - Use Viewpager with NavigationDrawer leads to Blank page -


when click items of navigationdrawer,the main activity container switch fragments show,it worked fine until met this:

1.switched fragmenta, contains viewpager,it showed well.

2.switched fragmentb,fragmentb showed well.

3.swiched fragmenta,it shows blank view

i tried flip horizontally on it,i can see viewpager index changed(in log),but don't know why showed blank page. *and,if fragmenta dose not contains viewpager,it worked well

any suggestion appreciated.

i use replace() switch between fragments:

fragmentmanager fragmentmanager = getsupportfragmentmanager();         fragmentmanager.begintransaction()                 .replace(r.id.container, currentfragment)                 .commit(); 

possible reason might not using replace transaction instead mightbe adding fragments , adding backstack. try using replace transaction, , see if works.

fragment1 firstfragment = new fragment1(); bundle bundle = new bundle(); firstfragment.setarguments(bundle); getsupportfragmentmanager().begintransaction() .replace(r.id.article_fragment, firstfragment) .commit(); 

learn more on fragments adding stack: android fragment transaction: fragmentmanager , backstack


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -