谁能告诉我 Inflator 是什么以及如何在 Android 应用程序中使用它?
我不知道它的确切用途以及为什么要使用它。
最佳答案
我首选的处理通货膨胀的方法:
//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 布局。通常您会继续将这些新 View 插入到先前定义的 ViewGroups 或 List 对象中。
关于android - Android 应用程序开发中的充气器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3861434/