0

I'm trying to change the font in my Android app with the code below. However, it keeps throwing setTypeFace() cannot be resolved at me and I don't know why.

navListView = (ListView) findViewById(R.id.nav_listView);

// Font path
String ralewayBold = "fonts/Raleway-Bold.ttf";
String ralewayExtraBold = "fonts/Raleway-ExtraBold.ttf";
String ralewayExtraLight = "fonts/Raleway-ExtraLight.ttf";
String ralewayHeavy = "fonts/Raleway-Heavy.ttf";
String ralewayLight = "fonts/Raleway-Light.ttf";
String ralewayMedium = "fonts/Raleway-Medium.ttf";
String ralewayRegular = "fonts/Raleway-Regular.ttf";
String ralewaySemiBold = "fonts/Raleway-SemiBold.ttf";
String ralewayThin = "fonts/Raleway-Thin.ttf";

// Loading Font Face
Typeface tf = Typeface.createFromAsset(getApplicationContext()
            .getAssets(), ralewayLight);

// Applying font
navListView.setTypeface(tf);
user3740505
  • 141
  • 3
  • 13

2 Answers2

2

setTypeface is a method of TextView and not of ListView.

If you want to set custom font style to text in ListView you have to do it in getView of your custom adapter

Apoorv
  • 13,470
  • 4
  • 27
  • 33
0

Its because you set typeface to listview directly.To set typeface to listview use custom adapter and settypeface in getView method in adapter.

To set typeface see these post

Custom font for Android listview

android change listview font and color

Community
  • 1
  • 1
Giru Bhai
  • 14,370
  • 5
  • 46
  • 74