android - How many LayoutInflater are instantiated in an application? -
i using factory interface on layoutinflater able set custom typeface on textview in application. unfortunately there places in application doesn't work. after investigation, seems in adapter of listview example, layoutinflater used inflate cells different 1 has been used fo rest of application (my activity has complex structure fragments).
is behaviour normal ? how can make sure same layoutinflater used, whatever way retrieve ?
thanks
as reference layoutinflater context.getsystemservice(context.layout_inflater_service) (viewgroup.inflate , activity.getlayoutinflater convenient wrappers) presume returns reference same inflater service, until destroyed , recreated, , newly created returned, , on... presume manager object aquired getsystemservice method sth "normal" service's binder objects.
edit: , saying above wrong ;)
i checked out source code , in android.view.contextthemewrapper (which activitie's super class):
@override public object getsystemservice(string name) { if (layout_inflater_service.equals(name)) { if (minflater == null) { minflater = layoutinflater.from(mbase).cloneincontext(this); } return minflater; } return mbase.getsystemservice(name); } and in android.app.contextimpl mbase context implementation:
public object getsystemservice(string name) { servicefetcher fetcher = system_service_map.get(name); return fetcher == null ? null : fetcher.getservice(this); } where : private static final hashmap system_service_map = new hashmap();
and servicefetcher inner class caching , retrieving "system service instances".
what sure there 1 layoutinflater per activity/contextwrapper. more observations study sources, please ;)
Comments
Post a Comment