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" >
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 :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.