0

I'm trying to create a fonction to change the fonts of my app.

the aim is to create a function that I call at the end of the onCreate() or the getView() in my adapters.

but my Style test is causing a crash, I'm not sure I understand well. If someone have an idea, it would be welcomed.

EDIT: the code bellow is correct !

 public static boolean recursiveFontSetting(View v){

     if( v instanceof ViewGroup){
         for(int i = 0;i<((ViewGroup) v).getChildCount();i++){
             recursiveFontSetting(((ViewGroup) v).getChildAt(i)); 
         }
         return true;
     } else if (v instanceof TextView){
        TextView e = (TextView) v;
        if(e.getTypeface()!=null && e.getTypeface().getStyle()==Typeface.BOLD){
            e.setTypeface(Constants.fontBold, Typeface.NORMAL);
        }else{

        e.setTypeface(Constants.fontReg);
        }
         return true;
     } 
     else if( v instanceof Button){
         Button e = (Button) v;
         if(e.getTypeface()!=null && e.getTypeface().getStyle()==Typeface.BOLD){
                e.setTypeface(Constants.fontBold, Typeface.NORMAL);
            }else{

            e.setTypeface(Constants.fontReg);
            }
         return true;
     }
     return false;
 }

Thanks !

Renaud Favier
  • 391
  • 6
  • 20

0 Answers0