I have been using Jake Wharton's ViewPagerIndicator and I am currently trying to implement a custom font on one of my fragments. I've tried using this code:
TextView txt = (TextView) findViewById(R.id.Zipcode);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/customfont.ttf");
txt.setTypeface(font);
In the onCreate
for the main activity which results in a null pointer exception in logcat and occasionally typeface cannot be made
. I've also tried to set the font in the fragment itself in both the onCreate
and onCreateView
however findViewById
and getAssests()
are unknown methods in the fragment scope.
I'm having trouble figuring out if the font is the problem or where I am trying to set the fon't is the problem.
Define typeface in yourViewHolder class`
like this.
You can try this
with this you can have the context in the scope of the fragment and get the view and the assets