вы используете этот конструктор.который запрашивает только контекст.
manager = new CardStackLayoutManager(getActivity());
Вы должны использовать это.Это будет работать для вас.
manager = new CardStackLayoutManager(getActivity(), this);
ваш полный код будет выглядеть следующим образом.
> public class UsersCardView extends Fragment implements
> CardStackListener {
> List<Spot> spotList;
>
> public UsersCardView() {
> // Required empty public constructor
> }
>
>
> @Override
> public View onCreateView(LayoutInflater inflater, ViewGroup container,
> Bundle savedInstanceState) {
> // Inflate the layout for this fragment
> View view =inflater.inflate(R.layout.fragment_users_card_view, container, false);
>
> //to set gradient on status bar
> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
> try{
> Window window = getActivity().getWindow();
> Drawable background = getResources().getDrawable(R.drawable.bg_gradient);
> window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
> window.setStatusBarColor(getResources().getColor(android.R.color.transparent));
> // window.setNavigationBarColor(getResources().getColor(android.R.color.transparent));
> window.setBackgroundDrawable(background);
>
> }
> catch(Exception e){
> Log.d("TAG", "UserCardView "+e);
> }
> }
>
> CardStackLayoutManager manager = new CardStackLayoutManager(getContext(),this);
> CardStackAdapter adapter = new CardStackAdapter(createSpot(),getContext());
> CardStackView cardStackView = view.findViewById(R.id.card_stack_view);
> cardStackView.setLayoutManager(manager);
> cardStackView.setAdapter(adapter);
> manager.setStackFrom(StackFrom.Bottom);
>
> manager.setVisibleCount(3);
> manager.setTranslationInterval(8f);
> manager.setDirections(Direction.FREEDOM);
> return view;
> }
>
> public List<Spot> createSpot()
> {
> spotList = new ArrayList<>();
> spotList .add(new Spot("Yasaka Shrine", "Kyoto", "https://source.unsplash.com/Xq1ntWruZQI/600x800"));
> spotList .add(new Spot("Fushimi Inari Shrine", "Kyoto", "https://source.unsplash.com/NYyCqdBOKwc/600x800"));
> spotList .add(new Spot("Bamboo Forest", "Kyoto", "https://source.unsplash.com/buF62ewDLcQ/600x800"));
> spotList .add(new Spot("Brooklyn Bridge", "New York", "https://source.unsplash.com/THozNzxEP3g/600x800"));
> spotList .add(new Spot("Empire State Building","New York", "https://source.unsplash.com/USrZRcRS2Lw/600x800"));
> spotList .add(new Spot("The statue of Liberty","New York", "https://source.unsplash.com/PeFk7fzxTdk/600x800"));
> spotList .add(new Spot("Louvre Museum", "Paris","https://source.unsplash.com/LrMWHKqilUw/600x800"));
> spotList .add(new Spot("Eiffel Tower", "Paris", "https://source.unsplash.com/HN-5Z6AmxrM/600x800"));
> spotList .add(new Spot("Big Ben", "London","https://source.unsplash.com/CdVAUADdqEc/600x800"));
> spotList .add(new Spot("Great Wall of China", "China", "https://source.unsplash.com/AWh9C-QjhE4/600x800"));
> return spotList;
> }
>
> @Override
> public void onCardDragging(Direction direction, float v) {
> Toast.makeText(this.getContext()," dragging"+direction,Toast.LENGTH_LONG).show();
> }
>
> @Override
> public void onCardSwiped(Direction direction) {
> Toast.makeText(this.getContext()," Direction "+direction,Toast.LENGTH_LONG).show();
> }
>
> @Override
> public void onCardRewound() {
>
> }
>
> @Override
> public void onCardCanceled() {
>
> }
>
> @Override
> public void onCardAppeared(View view, int i) {
>
> }
>
> @Override
> public void onCardDisappeared(View view, int i) {
>
> } }