I wrote the following statement to create an ArrayAdapter<String>
,
ArrayAdapter<String> arrayListAdapter = new ArrayAdapter<String>(getActivity(), R.layout.fragment_result_titles, R.layout.row_listview, arrayList);
But I got the error that the constructor call is ambiguous.
I understand that when null is passed, it is not clear which among ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)
and ArrayAdapter(Context context, int resource, int textViewResourceId, List<T> objects)
are we calling.
But then I tried this:
ArrayList arrayList = null;
ArrayAdapter<String> arrayListAdapter = new ArrayAdapter<String>(getActivity(), R.layout.fragment_result_titles, R.layout.row_listview, arrayList);
This does not give the error, although I am still passing null
, isn't it?
Why is this happening?