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

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -