How do I change to a Holo Dark/Light themes from within the app?

后端 未结 2 902
悲哀的现实
悲哀的现实 2020-12-16 07:30

I know it\'s possible to have it so if I have a setting I can change between Holo.Light and Holo, however, I cannot seem to find out how. All help is appreciated!

2条回答
  •  无人及你
    2020-12-16 07:51

    I think that you can do it by using the setTheme() method. Just make sure that you call it before you use setContentView, or it won't work.

    For example:

    if(userChoice ==1){
       setTheme(android.R.style.Theme_Holo_Light);
    else if(userChoice == 2){
        setTheme(android.R.style.Theme_Holo);
    }
    

    A list of themes can be found here

提交回复
热议问题