Reputation: 1617
Referring to the below codes. I wanted to know why do I need to put in one object and not all the objects from the strings. This codes are from a Custom ListView Adapter.
public ArrayAdapter (Context context, int textViewResourceId, T[] objects)
Working Fine
public ListViewAdapter(Context context, String[] first, String[] second, String[] third) {
super(context, R.layout.listview_item, first);
this.context = context;
this.first = first;
this.second = second;
this.third = third;
}
Error if I do this.
public ListViewAdapter(Context context, String[] first, String[] second, String[] third) {
super(context, R.layout.listview_item, first, second, third);
this.context = context;
this.first = first;
this.second = second;
this.third = third;
}
Error : The constructor ArrayAdapter(Context, int, String[], String[], String[]) is undefined
Original Source
public class ListViewAdapter extends ArrayAdapter<String> {
Context context;
String[] first;
String[] second;
String[] third;
LayoutInflater inflater;
public ListViewAdapter(Context context, String[] first, String[] second, String[] third) {
super(context, R.layout.listview_item, first);
this.context = context;
this.first = first;
this.second = second;
this.third = third;
}
Upvotes: 0
Views: 291
Reputation: 93892
You should read about the principle of inheritance in Java. Your class is extending ArrayAdapter.
If you take a look at it, you see that no constructors of type ArrayAdapter(Context, int, String[], String[], String[])
are defined for this class.
That's why you can't do super(context, R.layout.listview_item, first, second, third);
Upvotes: 2