Android - how to get the layout id from a view? -
hello fellow developers!
i'll keep simple , short can, have fragment, , in oncreateview giving different layouts depend on status.
is there way of knowing on layout am?
code below:
my oncreateview:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view; if (programstate) { view = inflater.inflate(r.layout.fragment_home_program_on, container, false); } else { view = inflater.inflate(r.layout.fragment_home, container, false); } findviews(view); setupviews(); return view; }
basically, "findviews" method gets view, , wondering if there's way know layout on switch statement example or that.. :
private void findviews(view mainview) { switch(mainview) { case r.layout.fragment_home: //do work break; case r.layout.fragment_home_program_on: //do work break; } }
i trying no success.. errors , such, there way that?
thanks lot in advance
is there way of knowing on layout am?
sure. check programstate
. doing determine layout load, use determine layout loaded.
i wondering if there's way know layout am
use if (programstate)
, same way did in oncreateview()
.
beyond that, widget has no idea layout resource came from. so, somewhere, need track information yourself, , seem doing in programstate
.
Comments
Post a Comment