6

आदेश PreferenceFragment में प्रत्येक पसंद के लिए कस्टम फोंट करने के लिए, मैं के लिए प्रत्येक प्राथमिकता प्रकार एक नया विशिष्ट वर्ग लिखना पड़ा (CustomSwitchPreference, CustomEditTextPreference, CustomListPreference, ....) और सेट अपने onBindView विधि में फ़ॉन्ट।PreferenceFragment बदलें संपत्ति फोंट के माध्यम से फ़ॉन्ट

यह काम करता है, लेकिन यह सबसे अच्छा समाधान है? कोई छोटा नहीं?

@Override 
public void onBindView(View view){ 
    super.onBindView(view); 
    TextView title = (TextView) view.findViewById(android.R.id.title); 
    TextView summary = (TextView) view.findViewById(android.R.id.summary); 
    Utils.setFont(context, title, customfont); 
    Utils.setFont(context, summary, customfont); 
} 

public class Utils{ 
    public static boolean setFont(Context context, TextView tv, String fontAssetName) { 
     Typeface font = Typeface.createFromAsset(context.getResources().getAssets(), fontAssetName); 
     if (font != null) { 
      tv.setTypeface(font); 
      return true; 
     } 
     return false; 
    } 
} 

वहाँ संवाद सहित PreferenceFragment के सभी वर्गों के लिए फ़ॉन्ट बदलने के लिए कोई तरीका है?

उत्तर

संबंधित मुद्दे