Reputation: 135
I have an android app that needs more than one theme. These themes are totally different from each other, but I need to know dynamically which theme is selected at the moment.
Here you can find an example of the application tag of my android app. Here you see the theme is set to Theme1, but it can be Theme2,Theme3,...
<application
android:name="be.genius.gticket.adapter.MyApplicationClass"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="gticket"
android:theme="@style/Theme1" >
Upvotes: 3
Views: 788
Reputation: 2618
int themeId = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.theme;
switch (themeId)
{
default:
case THEME_DEFAULT: // use the theme names in cases as per requirements
break;
case THEME_WHITE:
activity.setTheme(R.style.Theme_White);
break;
case THEME_BLUE:
activity.setTheme(R.style.Theme_Blue);
break;
}
I hope that helps :)
Upvotes: 3