I have a xml-layout file main with two textviews A/B and a view C.
I have two other xml-layout files option1 and option2.
Is it possible to load either option1 or option2 in run time via Java into C? If so, what function do I have to use?
I have a xml -layout file main with two textviews A/B and a view
Share
You could replace any view at any time.
If you don’t want to replace already existing View, but choose between option1/option2 at initialization time, then you could do this easier: set
android:idfor parent layout and then:You will have to set “index” to proper value depending on views structure. You could also use a ViewStub: add your C view as ViewStub and then:
That way you won’t have to worry about above “index” value if you will want to restructure your XML layout.