Meetic / Shuffle

An easy to use swiping-view for Android
886 stars 83 forks source link

OnClick Listener #10

Closed younes0 closed 8 years ago

younes0 commented 8 years ago

How would you set a Click Listener on the shuffle component ? I tried this with no success:

        shuffle.setOnClickListener(new Shuffle.OnClickListener() {
            @Override
            public void onClick(View view) {
                Debug.i("test");
                // Do something here
            }
        });
florent37 commented 8 years ago

Try direcly from the adapter's view Le 15 mai 2016 11:16, "Younes El Biache" notifications@github.com a écrit :

How would you set a Click Listener on the shuffle component ? I tried this with no success:

    shuffle.setOnClickListener(new Shuffle.OnClickListener() {
        @Override
        public void onClick(View view) {
            Debug.i("test");
            // Do something here
        }
    });

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/Meetic/Shuffle/issues/10

younes0 commented 8 years ago

Thanks, it worked.

public class ShuffleAdapter extends Shuffle.Adapter {

    @Override
    public Shuffle.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int type) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_swipe, viewGroup, false);

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

        return new Shuffle.ViewHolder(view);
    }
}
florent37 commented 8 years ago

👍