My PreferenceActivity looks like:
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.
The easiest way to change typeface for all TextViews in PreferenceScreen is:
public class WallpaperSettings extends PreferenceActivity {
private View tryInflate(String name, Context context, AttributeSet attrs) {
LayoutInflater li = LayoutInflater.from(context);
View v = null;
try {
v = li.createView(name, null, attrs);
} catch (Exception e) {
try {
v = li.createView("android.widget." + name, null, attrs);
} catch (Exception e1) {
}
}
return v;
}
protected void onCreate(Bundle savedInstanceState) {
//CHANGE TYPEFACE FOR ALL TEXTVIEWS
final Typeface font = Typeface.createFromAsset(getAssets(), "fonts/cabal.ttf");
getLayoutInflater().setFactory(new Factory() {
@Override
public View onCreateView(String name, Context context,
AttributeSet attrs) {
View v = tryInflate(name, context, attrs);
if (v instanceof TextView) {
((TextView) v).setTypeface(font);
}
return v;
}
});
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
}
That's it!