Java Eclipse说“构造函数未定义”
我有一个自定义的ArrayAdapter类:Java Eclipse说“构造函数未定义”,java,android,eclipse,Java,Android,Eclipse,我有一个自定义的ArrayAdapter类: public class DrawerArrayAdapter<T> extends ArrayAdapter<T> { int disabledItemPosition; @Override public boolean areAllItemsEnabled() { // TODO Auto-generated method stub return false; } @Override public b
public class DrawerArrayAdapter<T> extends ArrayAdapter<T> {
int disabledItemPosition;
@Override
public boolean areAllItemsEnabled() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isEnabled(int position) {
// TODO Auto-generated method stub
if(disabledItemPosition ==position){
return false;
} else {
return super.isEnabled(position);
}
}
public DrawerArrayAdapter(Context context, int resource) {
super(context, resource);
// TODO Auto-generated constructor stub
}
public DrawerArrayAdapter(Context context, int resource,
int textViewResourceId) {
super(context, resource, textViewResourceId);
// TODO Auto-generated constructor stub
}
public DrawerArrayAdapter(Context context, int resource, T[] objects) {
super(context, resource, objects);
// TODO Auto-generated constructor stub
}
public DrawerArrayAdapter(Context context, int resource, List<T> objects) {
super(context, resource, objects);
// TODO Auto-generated constructor stub
}
public DrawerArrayAdapter(Context context, int resource, List<T> objects, int disabledItemPosition) {
super(context, resource, objects);
// TODO Auto-generated constructor stub
this.disabledItemPosition = disabledItemPosition;
}
public DrawerArrayAdapter(Context context, int resource,
int textViewResourceId, T[] objects) {
super(context, resource, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}
public DrawerArrayAdapter(Context context, int resource,
int textViewResourceId, List<T> objects) {
super(context, resource, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}
}
但当我试图用以下方法构建它时:
new DrawerArrayAdapter<String>(this, R.layout.drawer_list_item, mPlanetTitles, 9)
Eclipse抱怨构造函数drawerrayadaptermainactivity,int,String[],int是未定义的字符串数组不能强制转换为List,可能我错过了带有String或t数组的4参数构造函数,但我认为这就是问题所在。Eclipse或者更确切地说是Java是正确的。你在哪里有这样的构造函数?关于错误消息,你不了解什么?很清楚,可能是因为它没有定义。您有一个接受数组的构造函数,还有一个接受列表和int的构造函数,但没有一个接受数组和int的构造函数。我的错误是,似乎我应该休息一下,正确的构造函数是:public drawerrayadaptercontext context,int resource,T[]objects,int disabledecomposition{supercontext,resource,objects;//TODO自动生成的构造函数存根this.disabledEmposition=disabledEmposition;}