0

I want to get the font of the application from database so that i can easily change it whenever i want. So can anyone please tell me how can i change the color of the whole application at run time, mean after getting it from database.

Zeeshan Ahmed
  • 1,179
  • 2
  • 13
  • 30

1 Answers1

1

You can create a static method in a class.

class Helper{
private static Typeface mType;
public static Typeface getTypeface(){
  if (mType!=null) return mType;
   else
    {
      mType=//Get typeface here
    }
 }
}

You won't have to get typeface from database more than once. You can customize it if you want more fonts.

Now all you have to do is call this method whenever you want to change font. For example:

textbox.setTypeface(Helper.getTypeface());

If you want to change font of each views in your app, here is best way of doing it.

Good luck!

Community
  • 1
  • 1
Bipin Bhandari
  • 2,694
  • 23
  • 38