充气的Andr​​oid应用程序开发程序开发、Andr、oid

由网友(酷到爆炸∴)分享简介:有人能告诉什么充气,以及它如何被在Android应用程序中使用?Can anybody please tell What Inflator is and how it is being used in an Android application?我不知道它的确切用途,以及为什么它被使用。I don't know...

有人能告诉什么充气,以及它如何被在Android应用程序中使用?

Can anybody please tell What Inflator is and how it is being used in an Android application?

我不知道它的确切用途,以及为什么它被使用。

I don't know the exact use of it and Why it is being used.

推荐答案

我的preferred的方式来处理通胀的:

My preferred way to handle inflation:

//First get our inflater ready, you'll need the application/activity context for this
LayoutInflater mInflater;
mInflater = LayoutInflater.from(mContext);

//Inflate the view from xml
View newView = mInflater.inflate(R.layout.my_new_layout, null);

//Then you'll want to add it to an existing layout object
mMainLayout.add(newView);

//Or perhaps just set it as the main view (though this method can also 
// inflate the XML for you if you give it the resource id directly)
setContentView(newView);

基本上,你用它来抬高现有的XML布局在运行时。通常你继续前进,插入这些新观点为previously定义ViewGroups或列表的对象。

Basically, you use it to inflate existing xml layouts at runtime. Usually you go ahead and insert those new views into previously defined ViewGroups or List objects.

阅读全文

相关推荐

最新文章