android - NullPointerException with custom font from assets -
i'm trying use custom font in application, got exception when when run app:
caused by: java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.textview.settypeface(android.graphics.typeface)' on null object reference i have working font , it's in right path , that's code:
private textview tv; private typeface tf; tv = (textview) findviewbyid(r.id.wlctext); tf = typeface.createfromasset(getassets(), "en_font.ttf"); tv.settypeface(tf); that's xml:
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:id="@+id/mainview" android:background="@color/semi_transparent_black" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="@dimen/activity_vertical_margin"> <textview android:id="@+id/wlctext" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textcolor="@android:color/white" android:text="test" android:textsize="25sp" /> </linearlayout>
tv null. whatever reason (e.g., failure call setcontentview()), not have widget in activity can found via r.id.wlctext.
Comments
Post a Comment