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 7735971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:38:02+00:00 2026-06-01T07:38:02+00:00

I created a sample application using Android TextView with shared preferences . In my

  • 0

I created a sample application using Android TextView with shared preferences. In my application i have a sample textview which contains some text (Eg. “Android Font Text”), and also a had set of fonts in my assets folder. Here my requirement is, when i touch the textview, a sample dialog will popup in this pop up i shows the list of font’s in assets folder. When i select any one of the font it was changed successfully, it persist only in that particular activity. When i back to next activity the text view remains in default style. Here how can i achieve shared preferences for fonts. I can’t pass the type face object through the editor. I used like this,

  Typeface font = Typeface.createFromAsset(getAssets(),"digit_fonts/AKEI____.TTF");
    font.isBold();
    mTextView.setTypeface(font);
    font_editor = font_pref.edit();
    font_editor.putString("font_style", font.toString());
    font_editor.commit();

Unfortunately it won’t works, how can i acheive, if any one solve my problem. Thanks in Advance.

  • 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-01T07:38:03+00:00Added an answer on June 1, 2026 at 7:38 am

    So, you’re trying to load a font from sharedpreferences whenever an activity is started?

    If I’m understanding you correctly, what you need to do is
    1) Save the file name of the font the user has chosen (i.e., “digit_fonts/AKEI__.TTF”)
    2) Load the font using the file name saved in shared preferences, for example:

    Typeface font = Typeface.createFromAsset(getAssets(),font_pref.getString("font_style", default_font_filename));
    

    Then apply the font as you normally would.

    EDIT:

    To load:

    font_style = font_pref.getString("font_style", null);
    if (font_style!=null){
        Typeface font = Typeface.createFromAsset(getAssets(),font_style);
        font.isBold();
        mTextView.setTypeface(font);
    }
    

    To save:

    font_editor = font_pref.edit();
    font_editor.putString("font_style", font_style);
    font_editor.commit();
    

    As you can see, font_style is actually the file location of your font (the way I’ve coded it above). When the user chooses a font, you alter font_style then save it to preferences.

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

Sidebar

Related Questions

Hello i have created a sample application in android using eclipse IDE my code
I created a sample application using android sqlite database, my requirements are How can
Hi i created one sample application that saves data as text file using simple
I have created a sample java socket application. I used Socket s = new
I have created a simple win 32 application..in which it has a textbox and
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I created a sample hello world application using Flash Builder 4.5.1 (with the update
I have created a sample silverlight application and trying to populated DataGrid with Data
I am new to android. I just created a simple application using Aynctask. Basically,
I have created a simple Hello World Application using Flash Builder Burrito SDK. I

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.