Infinite Cycle View Pager 3D Item -- How to make NewActivity, when click one card

Viewed 15

I want to implement a special conversion that is popular on the net, namely "Infinite Cycle View Pager - GithubAndroid Library Dev Light" Here is the link:Infinite Cycle View Pager I think you know this, you can present cards that can be rotated in 3D, very design. I would like a menu system from this, if you click on the card, I would like to open a NewActivity window. It would basically be a video presentation. But the code below is "myAdapter.java", I transformed it, and in the setOnClickListener - Intent section so as you can see, it doesn't indicate a syntax error, it translates, it starts, but when I click on the card, the program exits with a program stop. What do you think could be wrong?

import android.content.Context;
import android.content.Intent;
import android.provider.ContactsContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
import java.util.List;

public class MyAdopter extends PagerAdapter {
    List<Integer> images;
    Context context;
    LayoutInflater layoutInflater;

    public MyAdopter(List<Integer> images, Context context) {
        this.images = images;
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return images.size();
    }
    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view.equals(object);
    }
    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View)object);
    }
    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, final int position) {
        View view= layoutInflater.inflate(R.layout.card_item,container,false);
        ImageView imageView =(ImageView)view.findViewById(R.id.imageview);
        imageView.setImageResource(images.get(position));
        container.addView(view);
        view.setOnClickListener(new View.OnClickListener()  {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, zoompresentationvideo.class);
                context.startActivity(intent);

                //Toast.makeText(context,"Clicked image show presentation " +position,Toast.LENGTH_LONG ).show();
            }

        });
        return view;
    }
}

Thank you in advance for your help.

0 Answers
Related