android - Before onCreateView starts -
in pagefragment; inflate layout in oncreateview. want inflate layout before oncreateview loads. inflated 1 time / or every fragment; not important.
how can achieve ?
public class pagefragment extends fragment { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.page_quiz, container, false); tv = (textview) view.findviewbyid(r.id.text); linearlayout ll = (linearlayout) view.findviewbyid(r.id.questionlist); return view; } }
you have provide layout return parameter in oncreateview()
, not means have inflate there. layout can come anywhere. can inflate layout in onattach()
or in oncreate()
.
use getactivity()
layoutinflater
instance:
view layout = layoutinflater.from(getactivity()).inflate(........);
Comments
Post a Comment