Question

I use this code to set Roboto font to a Textview for each item if my list.

It works fine but when i scrolml the list, it's not fluid whereas with default font, the list is verry fluid when i scroll.

TextView premiereLettre = (TextView) rowView.findViewById(R.id.premiere_lettre);
Typeface face = Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Light.ttf");
premiereLettre.setTypeface(face);

What is the problem ?

Can i make an enhancement for this code ?

Thanks a lot

Était-ce utile?

La solution

Problem is that you create TextView object, and most importantly a Typeface object each time you create a row. Create them once in your class (you can use ViewHolder for your TextView, and a class level variable for Typeface that you instantiate in your constructor)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top