我使用了构造函数,但它不起作用。
LayoutInflater layoutInflater = new LayoutInflater(getContext());
Android Studio 用红色下划线显示了以下代码
new LayoutInflater(getContext());
它说“LayoutInflator 是抽象的;无法实例化。
最佳答案
LayoutInflater
是抽象类,因此您不能直接创建它。您应该使用实用函数LayoutInflater.from(context)
。
关于java - 如何创建 LayoutInflater?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53978143/