[Solved] How to get the total count in cart using Recyclerview Adapter

use cartlist.size() for total count. and for using in activity define this in Adapter class: class ProductAdapter(private val.. { … fun getCartSize():Int { return cartlist.size() } … } and in the activity you can use : adapter.getCartsize() 2 solved How to get the total count in cart using Recyclerview Adapter

[Solved] My object is not null but I’m getting a NULL POINTER EXCEPTION

In the stacktrace I see this: java.lang.NullPointerException: Attempt to invoke interface method ‘int java.util.List.size()’ on a null object reference The adapter is trying to call size() on a null List. Make sure your list searchResults is not null. solved My object is not null but I’m getting a NULL POINTER EXCEPTION