本文介绍了充气的Andr​​oid应用程序开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉什么充气,以及它如何被在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.

这篇关于充气的Andr​​oid应用程序开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 22:51