Andrew
Andrew

Reputation: 8120

Clearing array adaptor resources in android

I've got a GridView on an activity and I'm setting a custom font in the constructor for the ArrayAdaptor like this

typeface = Typeface.createFromAsset(getContext().getAssets(), "RobotoCondensed-Light.ttf");

This seems fine and shows just one occurance of it when issuing

adb shell dumpsys meminfo com.example.app

If I then exit the activity and go into it again there's then two references to the font resource and so on for every time I enter it.

In what way should I be clearing up that. I can't think where that clear up process should go to release the resource.

Upvotes: 0

Views: 36

Answers (1)

serge
serge

Reputation: 1609

Instead of calling Typeface.createFromAsset in every activity you might want to create it once in the main app and use it to set font any time you want:

textView.setTypeface(mainApp.getTypeface());

Upvotes: 1

Related Questions