How to change the font of the MessageMessage EditTextPreference dialog in Android?

How to change the font of the MessageMessage EditTextPreference dialog in Android?

I want to change the default font style in a dialog box, but I don’t know how to do it!

this is my Custom EditTextPreference:

public class MyEditTextPreferences extends EditTextPreference {

public MyEditTextPreferences(Context context) {
    super(context);
}


public MyEditTextPreferences(Context context, AttributeSet attrs) {
    super(context, attrs);
}


public MyEditTextPreferences(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}


@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
    titleView.setTypeface(G.yekanfont);
    summaryView.setTypeface(G.yekanfont);

} 
}

and this:

 <com.mydomain.mypackagename.MyEditTextPreferences
    android:defaultValue="300"
    android:dialogMessage="some text"
    android:dialogTitle="some other text"
    android:inputType="number"
    android:key="DURATION_BETWEEN"
    android:title="some text"        
    android:summary="some other text"
     />
+4
source share
1 answer

You need to do this in onCreateView. Like this:

@Override
protected View onCreateView(ViewGroup viewGroup) {
    View v = super.onCreateView(viewGroup);
    try {
        TextView titleView = (TextView) v.findViewById(android.R.id.title);
        titleView.setTypeface(G.yekanfont);
        TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
        summaryView.setTypeface(G.yekanfont);
    } catch (Exception e) {
        Log.i("TAG", "Excpetion ", e);
    }

    return v;
}
0
source

All Articles