나는 안드로이드 초보자입니다. 나는 목록에서 어떤 것을 재정렬하는 기능을 가진 안드로이드 프로젝트를하고있다. 나는 https://github.com/commonsguy/cwac-touchlist#readme 에서 오픈 소스를 발견하고 모듈 이름은 CWAC입니다 : TouchListViewAndroid 드래그 앤 드롭 ListView 문제
하지만 내 구현하는 동안, 나는 제거를 턴 오프하는
I 싶어 몇 가지 문제가 누군가가 나를 도울 수 있기를 바랍니다 함수를 사용하면 가로로 목록 항목을 이동할 수 있지만 기능을 사용할 수 없습니다. TouchListView.onTouchEvent()의 사례에서 Remove 코드에 주석을 달면 MotionEvent.ACTION_CANCEL 예기치 않은 동작이 발생합니다.
또한 돌고래 브라우저 북마크 페이지와 같은 항목을 드래그하는 동안 애니메이션이 필요하지만 DragListener를 구현해야하는지 잘 모르겠습니까 ??
그러나 버그가 수정되었습니다.
@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);
}
나는 list.getCount 위에 항목을 드래그하면 MotionEvent.ACTION_CANCEL는,이 예외가 발생합니다 경우에 대한
, 그래서 나는
에 조건을if (mDropListener != null && mDragPos >= 0 && mDragPos < getCount()) {
mDropListener.drop(mFirstDragPos, mDragPos);
}
에서
교체
if (mDropListener != null && mDragPos >= 0 && mDragPos < getCount() - 1) {
mDropListener.drop(mFirstDragPos, mDragPos);
}
그런 다음 예외가 수정됩니다.
아무도 나를 도울 수 있습니까 ?? 많은 감사. 나는 수평의 목록 항목을 이동할 때
오, 감사합니다. 지금 제거 기능을 끌 수 있습니다. 그리고 애니메이션을 구현하려고합니다. 이 기능을 구현할 수 있다면 솔루션을 게시 할 수 있습니다. – Rebecca