android - Fragment callback on attach complete in Activity -
is possible attach complete of fragment in hosting activity? new android.
here code add fragment:
fragmentmanager fm = getsupportfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); decorationfragment fragment = new decorationfragment(); ft.add(r.id.fragmentcontainer,fragment,"decoration_fragment"); ft.commit();
i have 2 objects in fragment. want handle click event in activity.
public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view rootview = inflater.inflate(r.layout.fragment_decoration, container, false); mchangetextcolorbutton = (button) rootview.findviewbyid(r.id.changetextcolorbutton); mcolorpallette = (linearlayout)rootview.findviewbyid(r.id.color_pallette_linearview); return rootview; }
how achieve this?
not sure you're asking, perhaps you're looking for:
void onattachfragment (fragment fragment)
called when fragment attached activity.
this called after attached fragment's
onattach
, before attached fragment'soncreate
if fragment has not yet had previous calloncreate
.
Comments
Post a Comment