从Android的XML文件中创建视图的对象 [英] Create View-Object from XML file in android

查看:114
本文介绍了从Android的XML文件中创建视图的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想从一个XML布局文件的对象,而不必落实到当前布局。

I only want to get an object from a xml layout file without having to implement it into the current layout.

我知道的方式

LayoutInflater.from(context).inflate(R.layout.myfile, myparent, true);

但执行上面的布局后,将实施,在我的myparent - 查看立即显示,对不对?我只想要得到的对象本身来获得它的属性和这样的。也许(但仅也许)以后将其插入显示的布局。 这可能吗?

but after execution of the above the layout will be implemented and shown immediately inside my "myparent"-View, right? I only want to get the Object itself to get its attributes and such. And maybe (but only maybe) insert it later into the shown layout. Is that possible?

问候

推荐答案

您应该改变你的行:

LayoutInflater.from(context).inflate(R.layout.myfile, null);

您可以找到它在文件<一个href="http://developer.android.com/reference/android/view/LayoutInflater.html#inflate%28int,%20android.view.ViewGroup%29">here.

这篇关于从Android的XML文件中创建视图的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆