layoutinflater.inflate

   前段时间提取拨号键盘控件,使用的是XML资源文件,结果一直没有内容,用Layout-inspector查看也是没有内容,几经排查发现原来是在引入ui时使用inflate()不当导致的,具体看源码

/**
 * Inflate a new view hierarchy from the specified xml resource. Throws
 * {@link InflateException} if there is an error.
 * 
 * @param resource ID for an XML layout resource to load (e.g.,
 *        <code>R.layout.main_page</code>)
 * @param root Optional view to be the parent of the generated hierarchy.
 * @return The root View of the inflated hierarchy. If root was supplied,
 *         this is the root View; otherwise it is the root of the inflated
 *         XML file.
 */
 View convertView = inflater.inflate(R.layout.layout_dialpad,null);

因为我是直接继承LinearLayout,作为控件容器,但是父容器却置为null,这就导致控件和资源文件的脱节。