[英]How to create custom view from xml-layout?
I have the xml layout, and I want to create View from it - I need do it programatically. 我有xml布局,我想从中创建View - 我需要以编程方式进行。 Is it possible?
可能吗?
yes It is. 是的。 you have to use the inflater service like
您必须使用充气机服务,例如
LayoutInflater li=(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
yourview=li.inflate(R.layout.yourlayout, null);
put your xml in layout folder with some name say x. 将您的xml放在布局文件夹中,名称为x。
Use getViewInflate().inflate(R.layout.x, null, null) to create the view. 使用getViewInflate()。inflate(R.layout.x,null,null)来创建视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.