I am trying to use a custom font within a TextView of an Android Studio application, but am getting the following error:
It's a null pointer exception; in the below code, txt
is null
for some reason:
Java:
TextView txt;
txt.setText("A");
txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Grundschrift.ttf");
txt.setTypeface(font);
XML:
android:id="@+id/custom_font"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="A"
Thanks!