首页 > 其他 > 详细

LayoutInflater.Factory的妙用

时间:2014-02-20 08:08:14      阅读:396      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
自定义实现个Factory,可以用来解析自定义的属性。
public interface Factory { /** * Hook you can supply that is called when inflating from a LayoutInflater. * You can use this to customize the tag names available in your XML * layout files. * * <p> * Note that it is good practice to prefix these custom names with your * package (i.e., com.coolcompany.apps) to avoid conflicts with system * names. * * @param name Tag name to be inflated. * @param context The context the view is being created in. * @param attrs Inflation attributes as specified in XML file. * * @return View Newly created view. Return null for the default * behavior.如果返回一个view, 那么就会直接加入到原有View树中去。 如果返回null,则会走原来类似于onCreate的方法。 */ public View onCreateView(String name, Context context, AttributeSet attrs); }
bubuko.com,布布扣

 LayoutInflater.Factory这个值设置到LayoutInflater中,而LayoutInflater的获得又是跟谁Context而来的。也就是说相同的Context有着相同的LayoutInflater,那就可以重用相同的LayoutInflater.factory

LayoutInflater.Factory的妙用

原文:http://www.cnblogs.com/xitang/p/3556630.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!