- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
谁能告诉我 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/
想问一下。有什么区别: LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(Conte
我正在使用 RecyclerView 来保存 CardView 列表。在我运行 Lollipop 5.0.2 的设备上,应用程序运行良好并且列表正确显示数据。然而,在其他 Lollipop 之前的设备
简单:我想用 1 个宽度为 0dp 的子项来膨胀父项。 父级 xml: 子类: public class KeyButton extends RelativeLayout implements Vi
我正在尝试创建一个 android 键盘,现在我希望它只是膨胀,即显示来自 main.xml 的线性布局 这是java文件 package keyboard.rob.com; import ... p
我有以下适配器 public class CardAdapter extends RecyclerView.Adapter{ List list; int id; Context context;
我的 main.xml 中目前有一个 DrawerLayout。 AppBarLayout 中包含了一个 Toolbar,然后是一个简单的 LinearLayout 来交换 fragment 。 我导
由于不推荐使用 Kotlin Synthetics,我们正在迁移到 ViewBinding。 我已经尝试了很多关于 ViewStub、ViewBinding 的谷歌搜索和阅读文档,并为 Fragmen
我无法使用 LayoutInflater 扩充 xml(包含 QuickContactBadge 的布局)文件,以便在 ListView 中使用它。它不会产生编译/运行时错误或正确的预期输出。从 XM
我是一名优秀的程序员,十分优秀!