Java 如何修复“未找到”或“未找到”错误?
我正在尝试显示自定义列表。我正在将字符串数组传递给customAdapter类。当我尝试访问GetLayoutFlater时,它没有被识别?我怎样才能解决这个问题Java 如何修复“未找到”或“未找到”错误?,java,android,Java,Android,我正在尝试显示自定义列表。我正在将字符串数组传递给customAdapter类。当我尝试访问GetLayoutFlater时,它没有被识别?我怎样才能解决这个问题 package com.parse.starter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java
package com.parse.starter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.ArrayList;
public class CustomAdapter extends BaseAdapter {
ArrayList<String> descriptions;
public CustomAdapter(final ArrayList<String> description) {
descriptions=description;
}
@Override
public int getCount() {
return descriptions.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
view=getLayotInflater(R.layout.rowcourses,null);
return null;
}
}
package com.parse.starter;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.BaseAdapter;
导入java.util.ArrayList;
公共类CustomAdapter扩展了BaseAdapter{
阵列列表描述;
公共CustomAdapter(最终ArrayList说明){
描述=描述;
}
@凌驾
public int getCount(){
返回descriptions.size();
}
@凌驾
公共对象getItem(int位置){
返回null;
}
@凌驾
公共长getItemId(int位置){
返回0;
}
@凌驾
公共视图getView(int位置、视图视图、视图组父级){
视图=GetLayoutFlater(R.layout.rowcourses,null);
返回null;
}
}
在这里,更改此构造函数
private Context context;
public CustomAdapter(Context context, final ArrayList<String> description) {
descriptions=description;
context = context;
}
在这里,更改此构造函数
private Context context;
public CustomAdapter(Context context, final ArrayList<String> description) {
descriptions=description;
context = context;
}
虽然这个答案可能有效,但你能为OP解释一下你的答案吗?这可以帮助他理解他做错了什么以及你的回答当我创建一个类为CustomAdapter CustomAdapter a=new CustomAdapter(Description)的对象时我应该传递什么;给出错误。@Sheildboy,如果您是从活动中调用,CustomAdapter a=new CustomAdapter(此,描述);从片段CustomAdapter a=newcustomadapter(getContext(),Description)@notTdar但是构造函数需要两个参数虽然这个答案可能有效,你能为OP解释一下你的答案吗?这可以帮助他理解他做错了什么以及你的回答当我创建一个类为CustomAdapter CustomAdapter a=new CustomAdapter(Description)的对象时我应该传递什么;给出错误。@Sheildboy,如果您是从活动中调用,CustomAdapter a=new CustomAdapter(此,描述);从片段CustomAdapter a=newcustomadapter(getContext(),Description)@notTdar但构造函数接受两个参数