Closed objque closed 8 years ago
Hi,
EasyAdapter
has several constructors but there isn't one to add a single item. The one you are using in the first case is:
/**
* Constructs and EasyAdapter with a Context, an {@link ItemViewHolder} class and a generic listener.
*
* @param context a valid Context
* @param itemViewHolderClass your {@link ItemViewHolder} implementation class
* @param listener a generic object that you can access from your {@link ItemViewHolder} by calling
* {@link ItemViewHolder#getListener()}, This can be used to pass a listener to the view holder that then you
* can cast and use as a callback.
*/
public EasyAdapter(Context context, Class<? extends ItemViewHolder> itemViewHolderClass, Object listener) {
super(context, itemViewHolderClass, listener);
mListItems = new ArrayList<>();
}
As you can see, the third parameter is a generic object that is intended to pass a listener/callback to your view holder, so the third parameter is NOT a data item for the adapter and that's why your code is not working. If you want, you can pass a list of data items in the constructor but not a single one.
Hello, if i try write this code:
I have empty listView. But if i write this code:![not empty](https://cloud.githubusercontent.com/assets/7000585/9445851/f78109a6-4a96-11e5-8fbd-ec45eafe0c5f.PNG)
Then already ok, What I'm doing wrong? I use retrofit+your library