关于将XML布局实例化view的对象写法

前端之家收集整理的这篇文章主要介绍了关于将XML布局实例化view的对象写法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

实例化为View对象1:

LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.list_item,null);
实例化为View对象2:
LinearLayout layout = (LinearLayout)LayoutInflater.from(context).inflate
(R.layout.list_item,null);
实例化为View对象3:
LinearLayout layout = (LinearLayout)View.inflate(context,R.layout.list_item,null);
实例化为View对象4:

LayoutInflater inflater =getLayoutInflater().inflate(R.layout.list_item,null);

附上参考网址:http://www.2cto.com/kf/201205/131136.html

原文链接:https://www.f2er.com/xml/296818.html

猜你在找的XML相关文章