android - FragmentTransaction not showing replaced fragment -
after replacing fragment container in main view new instance of fragment class, nothing seems happening
case 2: log.d("menu", "sent clicked"); try { android.support.v4.app.fragment fragment = new sentfragment(); fragmenttransaction fm = getsupportfragmentmanager().begintransaction(); fm.replace(r.id.framelayout, fragment); fm.commit(); getsupportfragmentmanager().executependingtransactions(); }catch(exception e){ e.printstacktrace(); } break; and logcat this
06-19 09:12:29.487 19458-19458/com.pacentltd.mail d/menu﹕ sent clicked 06-19 09:12:29.487 19458-19458/com.pacentltd.mail d/frag﹕ attached after calling onattach on fragment self
check modifications below
case 2: log.d("menu", "sent clicked"); try { sentfragment fragment = new sentfragment(); // updated line fragmenttransaction fm = getsupportfragmentmanager().begintransaction(); fm.replace(r.id.framelayout, fragment); fm.commit(); getsupportfragmentmanager().executependingtransactions(); }catch(exception e){ e.printstacktrace(); } break; create instance of sentfragment , not of android.support.v4.app.fragment. , make sure sentfragment class extends android.support.v4.app.fragment
Comments
Post a Comment