NullPointerException with custom font from assets
问题 I'm trying to use custom font in my application, but i got that exception when when run the app: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTypeface(android.graphics.Typeface)' on a null object reference I have a working font and it's in the right path and that's my code: private TextView tv; private Typeface tf; tv = (TextView) findViewById(R.id.wlcText); tf = Typeface.createFromAsset(getAssets(), "en_font.ttf"); tv