Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with RecyclerView #17

Closed
ghost opened this issue Jun 20, 2018 · 2 comments
Closed

Problems with RecyclerView #17

ghost opened this issue Jun 20, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 20, 2018

I'm using RecyclerView to show a list of questions and for each one, displayed inside a CardView .. it has a recordbutton and a recordview .. By clicking on the button and moving it up and taking it .. instead of canceling press the button again. I believe the problem is due to the existence of scroll .. but I can not solve it. If anyone has ideas to help ..

@3llomi
Copy link
Owner

3llomi commented Jun 20, 2018

Hey @phabiulla .
inspired by this , you can create your own custom RecyclerView to fix this issue like this:

public class CustomRecyclerView extends RecyclerView {
    public CustomRecyclerView(Context context) {
        super(context);
    }

    public CustomRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        final int action = ev.getAction();
        switch (action)
        {
            case MotionEvent.ACTION_DOWN:
                super.onTouchEvent(ev);
                break;

            case MotionEvent.ACTION_MOVE:
                return false; // redirect MotionEvents to ourself

            case MotionEvent.ACTION_CANCEL:
                super.onTouchEvent(ev);
                break;

            case MotionEvent.ACTION_UP:
                return false;

            default:  break;
        }

        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        super.onTouchEvent(ev);
        //Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() );
        return true;
    }
}

and use it in XML instead of android.support.v7.widget.RecyclerView

@3llomi 3llomi closed this as completed Jun 20, 2018
@ghost
Copy link
Author

ghost commented Jun 22, 2018

Thank you! You helped me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant