Question

I am looking for a way to set the theme of my view that is being created dynamically by my database in code. I have found the way to inflate the view from xml, but unfortunately my view is already created so I do not understand why it is not taking my predefined theme in my manifest.

The theme for my application is android:Theme.Light.NoTitleBar

So everything in my app looks like a 2.3 application, but all of a sudden when I add these textboxes and spinners through the code in a specific fragment and NOT xml, it adds them as HOLO themed items, even though I have not defined any holo theme anywhere in my code.

Any help is appreciated.

Was it helpful?

Solution

So it turns out that I had to inflate EVERY single view that I created in code from xml layouts. So for example I had to create a BASIC textview in an xml layout with just id,width, and height, and then when I created my view dynamically I used..

CORRECT

Textview tv = (TextView) inflater.inflate(R.layout.textview, null);

This allowed my dynamically created views to take the theme of the xml, which apparently uses the AppTheme, rather than whatever base theme is used when calling..

INCORRECT

TextView tv = new TextView();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top