java - BaseAdapter Fragment Change page -
public class listviewadapter extends baseadapter { . . . programlarfragment myfragment = new programlarfragment(); bundle bundle = new bundle(); bundle.putstring("asd","asdasdasdasd"); myfragment.setarguments(bundle); android.support.v4.app.fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction(); fragmenttransaction.replace(r.id.fragment_container, myfragment); fragmenttransaction.commit();
assuming context object appcompatactivity or actionbaractivity (deprecated)
try doing this;
programlarfragment myfragment = new programlarfragment(); bundle bundle = new bundle(); bundle.putstring("asd","asdasdasdasd"); myfragment.setarguments(bundle); /* use passed in context value , cast class has getsupportfragmentmanager assuming class creates adapter 1 of these class instances either appcompatactivity or actionbaractivity , cast 1 using, recommend using appcompatactivity actionbaractivity deprecated */ android.support.v4.app.fragmenttransaction fragmenttransaction = ((appcompatactivity)this.context).getsupportfragmentmanager().begintransaction(); fragmenttransaction.replace(r.id.fragment_container, myfragment); fragmenttransaction.commit();
please see:
http://developer.android.com/reference/android/support/v4/app/fragmentactivity.html
under known direct sub classes can see appcompatactivity
, indirect sub classes can see actionbaractivity
mentions deprecated
Comments
Post a Comment