Akarsh M
Akarsh M

Reputation: 1611

I got stuck in getAssests() in the below code

public class XYZ extends LinearLayout{

     TextView text  = (TextView) findViewById(R.id.kid_name);
    Typeface font = Typeface.createFromAsset(getAssets(), "eng111.ttf");
    text.setTypeface(font);
}

I just try to use the other format for the text and the problem is occurred "create the getAssets() method "

Where do I mistake ? please sort out this problem

Upvotes: 0

Views: 105

Answers (1)

Carnal
Carnal

Reputation: 22064

You need a Context, since you are not in an Activity you need to call:

getContext().getAssets();

Upvotes: 2

Related Questions