android - Type mismatch: cannot convert from FragmentOne to Fragment when create FragmentOne in seperate class? -
when fragment fr=new fragmentone(); gives me error if create fragmentone() class in same activity not give error when create fragmentone() out side of activity gives me error
public class mainactivity extends actionbaractivity implements navigationdrawerfragment.navigationdrawercallbacks { /** * fragment managing behaviors, interactions , presentation of * navigation drawer. */ private navigationdrawerfragment mnavigationdrawerfragment; /** * used store last screen title. use in * {@link #restoreactionbar()}. */ private charsequence mtitle; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mnavigationdrawerfragment = (navigationdrawerfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.navigation_drawer); mtitle = gettitle(); // set drawer. mnavigationdrawerfragment.setup(r.id.navigation_drawer, (drawerlayout) findviewbyid(r.id.drawer_layout)); fragment fr=new fragmentone(); fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmentmanager .begintransaction().replace(r.id.container, fr).commit(); } @override public void onnavigationdraweritemselected(int position) { // update main content replacing fragments }
guess problem package imports should have figured out. either use android.app.fragment (or) android.support.v4.app.fragment based on app requirements :-)
Comments
Post a Comment