最近学习安卓基础发现同一个需求不同视频里用的方法不一样,有的用getlayoutinflater().from(this).inflate ,有的用View.inflate,想知道这两个方法有什么区别
1条回答 默认 最新
pumpkin的玄学 2021-11-11 12:41关注你说的是 LayoutInflater.from(context).inflate 吧
其实View.inflate里面间接调用了 LayoutInflater.from(context).inflate
给你看一下View.inflate的源码public static View inflate(Context context, @LayoutRes int resource, ViewGroup root) { LayoutInflater factory = LayoutInflater.from(context); return factory.inflate(resource, root); }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报