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 an error that the constructor call is ambiguous.
I understand that when null is passed, it is not clear which of the ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects) and ArrayAdapter(Context context, int resource, int textViewResourceId, List<T> objects) we call.
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 an error, although I am still missing null , right?
Why is this happening?
source share