Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8423871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:50:45+00:00 2026-06-10T03:50:45+00:00

I have been using Jake Wharton’s ViewPagerIndicator and I am currently trying to implement

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:50:46+00:00Added an answer on June 10, 2026 at 3:50 am

    You can try this

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle     savedInstanceState) {
           View v = inflater.inflate(R.layout.fragment_layout, container, false);
           TextView txt = (TextView) v.findViewById(R.id.Zipcode);
           Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/customfont.ttf");
           txt.setTypeface(font); 
           return v;
    }
    

    with this you can have the context in the scope of the fragment and get the view and the assets

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using play 1.2.5rc4 for development of one app and I have
I have been using the storyboard to make an application and currently there are
I have been using a custom type for Money with my POCOs and tries
I have been using TortoiseSVN for some time and I really like it. I
I have been using Stanford POS Tagger to tag parts of speech in a
I have been using an API to do some work. This is how I
I have been using some Javascript to create a text field once an certain
I have been using CI just fine using the MySQL driver. I want to
I have been using Matlab 2011b and contourf/contourfm to plot 2D data on a
I have been using the following sort: var query = _cityRepository.GetAll( .OrderBy(item => item.RowKey.Substring(0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.