CopyPastor

Detecting plagiarism made easy.

Score: 0.8668530084781491; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2012-05-26
by Shankar Agarwal

Original Post

Original - Posted on 2012-05-26
by Shankar Agarwal



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Solution1:: Just call these method by passing parent view as argument.
private void overrideFonts(final Context context, final View v) { try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } } else if (v instanceof EditText) { ((TextView) v).setTypeface(Typeface.createFromAsset(context.getAssets(), "font.ttf")); } } catch (Exception e) { } } Solution2:: you can subclass the TextView class with your custom font and use it instead of textview.
public class MyEditView extends EditText{ public MyEditView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } public MyEditView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public MyEditView(Context context) { super(context); init(); } private void init() { if (!isInEditMode()) { Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "font.ttf"); setTypeface(tf); } } }
Solution1:: Just call these method by passing parent view as argument. private void overrideFonts(final Context context, final View v) { try { if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; for (int i = 0; i < vg.getChildCount(); i++) { View child = vg.getChildAt(i); overrideFonts(context, child); } } else if (v instanceof TextView ) { ((TextView) v).setTypeface(Typeface.createFromAsset(context.getAssets(), "font.ttf")); } } catch (Exception e) { } }
Solution2:: you can subclass the TextView class with your custom font and use it instead of textview.
public class MyTextView extends TextView { public MyTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public MyTextView(Context context) { super(context); init(); } private void init() { if (!isInEditMode()) { Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "font.ttf"); setTypeface(tf); } } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;