Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:39:34+00:00 2026-05-25T00:39:34+00:00

I am a android beginner. I am doing a android project which has a

  • 0

I am a android beginner.
I am doing a android project which has a function to reorder something in a list.
I found a open source at https://github.com/commonsguy/cwac-touchlist#readme
and the module name is CWAC: TouchListView

But during my implementation, I have some problems and hope someone can help me,

  1. I wanna to turnoff the remove function when I move the list item at horizontal but I cannot…
    If I comment the remove code at TouchListView.onTouchEvent()’s case MotionEvent.ACTION_CANCEL
    It will occur the unexpected behavior.

  2. Also, I wanna have something animation during dragging the item like dolphin browser bookmark page, but I don’t know is it should be implements the DragListener??

However, I have a bug fixed on it.

@Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (mGestureDetector != null) {
            mGestureDetector.onTouchEvent(ev);
        }
        if ((mDragListener != null || mDropListener != null) && mDragView != null) {
            int action = ev.getAction();
            switch (action) {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                Rect r = mTempRect;
                mDragView.getDrawingRect(r);
                stopDragging();

                if (mRemoveMode == SLIDE_RIGHT && ev.getX() > r.left + (r.width() * 3 / 4)) {
                    if (mRemoveListener != null) {
                        mRemoveListener.remove(mFirstDragPos);
                    }
                    unExpandViews(true);
                } else if (mRemoveMode == SLIDE_LEFT && ev.getX() < r.left + (r.width() / 4)) {
                    if (mRemoveListener != null) {
                        mRemoveListener.remove(mFirstDragPos);                      
                    }
                    unExpandViews(true);
                } else {
                    if (mDropListener != null && mDragPos >= 0 && mDragPos < getCount() - 1) {
                        mDropListener.drop(mFirstDragPos, mDragPos);
                    }
                    unExpandViews(false);
                }
                break;

            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
                int x = (int) ev.getX();
                int y = (int) ev.getY();
                dragView(x, y);
                int itemnum = getItemForPosition(y);
                if (itemnum >= 0) {
                    if (action == MotionEvent.ACTION_DOWN || itemnum != mDragPos) {
                        if (mDragListener != null) {
                            mDragListener.drag(mDragPos, itemnum);
                        }
                        mDragPos = itemnum;
                        doExpansion();
                    }
                    int speed = 0;
                    adjustScrollBounds(y);
                    if (y > mLowerBound) {
                        // scroll the list up a bit
                        speed = y > (mHeight + mLowerBound) / 2 ? 16 : 4;
                    } else if (y < mUpperBound) {
                        // scroll the list down a bit
                        speed = y < mUpperBound / 2 ? -16 : -4;
                    }
                    if (speed != 0) {
                        int ref = pointToPosition(0, mHeight / 2);
                        if (ref == AdapterView.INVALID_POSITION) {
                            // we hit a divider or an invisible view, check
                            // somewhere else
                            ref = pointToPosition(0, mHeight / 2 + getDividerHeight() + 64);
                        }
                        View v = getChildAt(ref - getFirstVisiblePosition());
                        if (v != null) {
                            int pos = v.getTop();
                            setSelectionFromTop(ref, pos - speed);                          
                        }
                    }
                }
                break;
            }
            return true;
        }
        return super.onTouchEvent(ev);
    }

For the case MotionEvent.ACTION_CANCEL, if I drag the item over the list.getCount, it will throw exception, so I replace the condition

from

if (mDropListener != null && mDragPos >= 0 && mDragPos < getCount() ) {
      mDropListener.drop(mFirstDragPos, mDragPos);
}

to

if (mDropListener != null && mDragPos >= 0 && mDragPos < getCount() - 1) {
      mDropListener.drop(mFirstDragPos, mDragPos);
}

Then the exception will be fixed.

Could anyone can help me??
Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:39:34+00:00Added an answer on May 25, 2026 at 12:39 am

    I wanna to turnoff the remove function when I move the list item at horizontal but I cannot

    Use the custom remove_mode attribute with a value of "none". For example:

    <?xml version="1.0" encoding="utf-8"?>
    <com.commonsware.cwac.tlv.TouchListView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tlv="http://schemas.android.com/apk/res/com.commonsware.cwac.tlv.demo"
    
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:drawSelectorOnTop="false"
        tlv:normal_height="64dip"
        tlv:grabber="@+id/icon"
        tlv:remove_mode="none"
    />
    

    I wanna have something animation during dragging the item like dolphin browser bookmark page, but I don’t know is it

    I will not be able to help you with that, sorry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am beginner in Android app development i am working on a app which
I am a beginner in Android game development, while searching i found Rokon, a
i am doing a project in android. i am a begineer in android also.
I am a beginner to android, i am building a application in which when
I am a beginner of Android apps and am using Eclipse. I have found
First off I am a beginner in Android development; I have been doing a
I am beginner to android... Am trying following: In list of spinner items if
I'm a beginner at Android and there's an existing Android project I'd like to
I am an android beginner. I'm struggling to understand why startActivity runs properly when
I'm beginner of Android. I want to run my first application on emulator. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.