Are you sure you followed the example exactly? This error usually happens when you try to instantiate an interface or I believe also with an abstract class, by nature neither of which can be instantiated. Check to see if your implementation of CustomAdapter
is either of those.
In your second example, you're creating an anonymous subclass/implementation of CustomAdapter
and so you have a concrete instantiable class and the error goes away.