Sígvardr Ólavrsson Sígvardr Ólavrsson - 3 months ago 14
Java Question

Android - Adapters in fragments issue

I am fairly new to android development and when I try to work with adapters in fragments I get an error, I tried to write this line under the

onCreateView


valueAdapterEn = new ValueAdapterEn(English_list, this);


this error is in this section
(English_list, this)


ValueAdapterEn

public class ValueAdapterEn extends BaseAdapter implements Filterable {

private ArrayList<String> English_List;
private ArrayList<String> Filterd_EngList;
private LayoutInflater mInflater;
private ValueFilter valueFilter;

public ValueAdapterEn(ArrayList<String> English_List, Context context){
this.English_List = English_List;
this.Filterd_EngList = English_List;
mInflater = LayoutInflater.from(context);
getFilter();
}

@Override
public int getCount() {
return 0;
}

@Override
public Object getItem(int position) {
return null;
}

@Override
public long getItemId(int position) {
return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
return null;
}

@Override
public Filter getFilter() {
return null;
}
}


LogCat

Error:(84, 30) error: constructor ValueAdapterEn in class ValueAdapterEn cannot be applied to given types;
required: no arguments
found: ArrayList<String>,TwoFragment
reason: actual and formal argument lists differ in length


the problem may be with 'this'

Answer

You have create this ValueAdapterEn class with no arguments in the constuctor as the log message shows there I guess.How can you pass arguments in the class.Please also post your relevant code for more help and also learn core-java first before deep digging into some android code.You can lean about constructor from this and this.