我的ListAdapter类构造函数中有一个错误

时间:2016-04-15 08:20:19

标签: android listview listadapter

这是代码:

ListAdapter adapter = new ListAdapter(this, jenres, pics);

(alt + enter)没有帮助,它说“ListAdapter中的ListAdapter()无法应用于: 预期的实际 参数参数 !!

2 个答案:

答案 0 :(得分:0)

因为你没有在ListAdapter类中拥有所需的匹配构造函数。将构造函数创建为:

public ListAdapter(Context context, yourJenresType jenres, yourPicsType pics)  {
// do stuff
}

答案 1 :(得分:0)

在您的主要课程中,签名: -

ListAdapter adapter = new ListAdapter(Activityname.this, jenres, pics);

在ListAdpater中: -

public class ListAdapter extends YourAdapter{
Context context;
VariableType jenres;
VariableType pics;

//Constructor:

public ListAdapter(Context context, VariableType jenres, VariableType pics){
this.context= context;
this. jenres=jenres;
this.pics=pics;

}

//Adapter methods below
}