0

My activity has a default theme. When I press a button I want to change the theme, but also want that the activity's state to remain unmodified (if I had some text in an editText, I want to see this text after I changed the theme)

Is this possible?

Tünde
  • 885
  • 4
  • 11
  • 24

1 Answers1

0

Changing the style after creating the view is not supported .. so what you can do is:

  1. create a new android xml file of type values
  2. add new theme
  3. add your elements to that theme and their values and save the file

Now when you are dynamically creating the new view you call the constructor that will allow to define a defStyle .. then you point to the style ID you have just created by pointing to R."the XML file name"."your style ID"

hakki
  • 6,181
  • 6
  • 62
  • 106