How to modify the source of a list in android?

1

What I want to do is that my list in my android app have a different letter with more style, I already have fonts of type .ttf in the assets folder and I already did it with a textview but I could not implement it in a list

Here is my Java class builder

Context context;
    int layoutResourceId;
    Typeface tf;

    public AyudarApp(Context context, int layoutResourceId,String FONT ) {
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        tf = Typeface.createFromAsset(context.getAssets(), FONT);
    }

This way I assign everything to my constructor

    AyudarApp my_adapter = new AyudarApp(AyudarApp.this , R.layout.activity_ayudar ,"font/Cursive standard.ttf");
    mListView.setAdapter((ListAdapter) my_adapter);

The error is that when wanting to enter where my list is, it shows me that the application has stopped working and it takes me out of the app

    
asked by David 14.11.2016 в 01:20
source

1 answer

0

To load a source from Assets to be used in your application, this is the correct way:

Typeface font = Typeface.createFromAsset(getContext().getAssets(), "myfuente.ttf");

In your application, the problem the problem about closing the application can occur for various reasons, including those that are not related to the loading of the source.

What could prevent the problem when loading the font is the following,

  • Ensures having a context, variable context has no null value.
  • The variable FONT must contain a String that contains a String with the name of the source (extension .ttf).

:

tf = Typeface.createFromAsset(context.getAssets(), FONT);
    
answered by 14.11.2016 в 17:19