java - Error occurred in switching view in Fragment Navigation Drawer ,said no view found for fragment PlaceholderFragment -


i had created simple app via android studio using navigation drawer fragment.

i trying show view (like layout_about.xml) when user clicks item of listview.

so use setcontentview() in public void onnavigationdraweritemselected(int position) when run it, error occurred :

fatal exception: mainprocess: com.akakanch.sample, pid: 28848     java.lang.illegalargumentexception: no view found id 0x7f0c0050 (com.akakanch.sample:id/container) fragment placeholderfragment{250d0b42 #1 id=0x7f0c0050} 

here's place had change:

mainactivity.java

 @override     public void onnavigationdraweritemselected(int position) {         // update main content replacing fragments         fragmentmanager fragmentmanager = getsupportfragmentmanager();         fragmentmanager.begintransaction()                 .replace(r.id.container, placeholderfragment.newinstance(position + 1))                 .commit();         setcontentview(r.layout.layout_about);       } 

so, how can change view correctly?

it because calling set content view there. set layout want see layout of fragment replacing , see it

inside fragment:

   @override public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {           view view = inflater.inflate(r.layout.layout_about,container,false);         //do fragment stuff        return view;     } 

if when replace fragment using fragment manager see layout_about layout


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -