blipinsk / FlippableStackView

An Android library introducing a stack of Views with the first item being flippable.
Apache License 2.0
810 stars 150 forks source link

OnClicListener() && OnLongClicListener() doesn't work? #14

Closed mscdroidlabs closed 8 years ago

mscdroidlabs commented 8 years ago

Hi!

i have some problems to listen to this events, i tried to set clickable propertie in xml, also tried programattically "setClickacle(true)" but anything occurs. I only get working with OnTouchListener and then i have to play with ACTION_DOWN, ACTION_UP and ACTION_MOVE.

Anyone has tried?

blipinsk commented 8 years ago

Hi @mscdroidlabs can you check if the same issue occurs if you use a regular ViewPager instead of FlippableStackView?

mscdroidlabs commented 8 years ago

You want i try separately in other activity/fragment or i change any class of flippablestack?

blipinsk commented 8 years ago

You need to swap the one you're having problem with. What are you setting this OnClickListener on? On FlippableStackView object?

mscdroidlabs commented 8 years ago

`mPageAdapter = new ColorFragmentAdapter(getSupportFragmentManager(), mViewPagerFragments); mFlippableStack = (FlippableStackView) findViewById(R.id.flippable_stack_view); mFlippableStack.initStack(6, StackPageTransformer.Orientation.HORIZONTAL); mFlippableStack.setAdapter(mPageAdapter); mFlippableStack.setClickable(true); //Its hidden by default on my app mFlippableStack.setVisibility(View.VISIBLE);

                        mFlippableStack.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                Toast.makeText(getApplicationContext(), "mFlippableStack ClicListener! ", Toast.LENGTH_SHORT).show();
                            }
                        });

                        mFlippableStack.setOnDragListener(new View.OnDragListener() {
                            @Override
                            public boolean onDrag(View view, DragEvent dragEvent) {
                                Log.d("TT", "Drag : " + dragEvent.toString() );
                                return false;
                            }
                        });`

The content of fragments is displayed whithout problems but, no one of this events is executed... :S

blipinsk commented 8 years ago

Ok so you're trying to set an OnClickListener on a FlippableStackView itself. OnClickListener will not work for the FlippableStackView in the same way it will not work for the regular ViewPager. You can read the whole StackOverflow topic over here.

You should consider two things:

  1. Think if you really want to implement an OnClickListener on the FlippableStackView... Maybe it's the contents of the Stack that should be implementing this functionality?
  2. If you decide that it's really the FlippableStackView that needs that, try this approach.
mscdroidlabs commented 8 years ago

Nice! Big thanks!