Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we get the theme of an Activity?

I am trying to detect the theme used for an activity but so far I am only able to find that out for the entire application? Is there a way to do this?

like image 362
Frank Avatar asked Feb 20 '13 21:02

Frank


2 Answers

Just call the method getTheme() in your activity. For example.

public class MainActivity extends PreferenceActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Theme theme = this.getTheme();
    }
}
like image 131
androidyue Avatar answered Sep 28 '22 06:09

androidyue


My first thought would be ContextThemeWrapper.getTheme(), since Activity extends ContextThemeWrapper

like image 39
urSus Avatar answered Sep 28 '22 06:09

urSus