Facebook
From Rude Echidna, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 209
  1. package com.example.mimek.myapplication;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5.  
  6. public class themeUtils {
  7.     public static int theme;
  8.     public final static int DARK = 0;
  9.     public final static int LIGHT = 1;
  10.     public static void changeTheme(Activity activity, int t){
  11.         theme = t;
  12.         activity.finish();
  13.         activity.startActivity(new Intent(activity, activity.getClass()));
  14.     }
  15.     public static void onActivityCreate(Activity activity){
  16.         switch(theme){
  17.             case DARK:
  18.                 activity.setTheme(R.style.darkTheme);
  19.             case LIGHT:
  20.                 activity.setTheme(R.style.lightTheme);
  21.         }
  22.  
  23.     }
  24. }
  25.