gpt4 book ai didi

android - 解析 getLayoutInflater 时出错(未定义)

转载 作者:太空宇宙 更新时间:2023-11-03 11:29:07 26 4
gpt4 key购买 nike

当我用下面的代码编译程序时,发生了一个错误。它说 getLayoutInflater ( ) 未定义。我该如何解决?

 final LayoutInflater inflater = getLayoutInflater ( ); 

最佳答案

嗨,Prasanth,你可以试试这个

第 1 步:为 Layout Inflater 创建一个对象,如下所示:

LayoutInflater mInflater;

第二步:通过传递上下文进行初始化

Context context=MyActivity.getApplicationContext();
mInflater = LayoutInflater.from(context);

第三步:在获取 View 方法中,你可以将 View 设置为

public View getView(int arg0, View myView, ViewGroup parent) {


if (convertView == null) {

myView = mInflater.inflate(R.layout.mytest, null);
}

关于android - 解析 getLayoutInflater 时出错(未定义),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5065451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com