Skip to content
Advertisement

Clone textview to append it to a ViewGroup

I have a ViewGroup defined in XML with a view inside, at onCreate time I’d like to have a variable of those.
I don’t want to go through the hassle of using a listview+adapter cause its clearly overkill as I know the list won’t change since onCreate()
This is more or less the code I’d like to have.

JavaScript

But it is not working.

Advertisement

Answer

Maybe use an inflater, and put the textview in an external layout file:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement