There is a case where getItemCount
within the RecycerView
Adapter is not called for Android 4.0.3 (IceCreamSandwich
). All other API versions don't have any problems. I create my adapter as follows:
Log.i(LOG_TAG, "array size = " + myArray.size());
adapter = new MyListAdapter(context, myArray, this);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
I inserted the Log.i
to confirm there is an element in the array, which there is. Within the RecyclerView
Adapter's constructor, I have:
public MyListAdapter(Context context, List<dataModel> data, MyListener listener) {
this.context = context;
this.mData = data;
this.mInflater = LayoutInflater.from(context);
this.mListener = listener;
Log.i(LOG_TAG, "data size = " + this.mData.size());
}
And the data size is not empty within the constructor. What could be causing the getItemCount
to not be called when the adapter is created and set to a RecyclerView
? Again this only is happening with the IceCreamSandwich
API, all others work perfectly.