Inflative的方法有很多,这里简单的备份一下:
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.main, null); LayoutInflater inflater = LayoutInflater.from(context); (该方法实质就是第一种方法,可参考源代码) View layout = inflater.inflate(R.layout.main, null); LayoutInflater inflater = getLayoutInflater();(在Activity中可以使用,实际上是View子类下window的一个函数) View layout = inflater.inflate(R.layout.main, null); View layout = View.inflate(this, R.layout.main, null);
备注:
参考网站:
【 http://my.eoe.cn/addcn/archive/4215.html 】【 http://www.cnblogs.com/loyea/archive/2013/04/27/3047248.html 】
发表评论