【问题标题】:ListView's item - move on touchListView 的项目 - 触摸移动
【发布时间】:2013-12-17 07:33:26
【问题描述】:

我想通过拖动移动我的listview 的每个项目。 我为listview 设置了 OnTouch,并通过设置的左右边距拖放项目。 这是我的程序:

private void setLastViewDistance(float distanceX, View lastView) {
    if (lastView.getLayoutParams().getClass() == AbsListView.LayoutParams.class)
        lastView = ((ViewGroup) lastView).getChildAt(0);

    LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) lastView.getLayoutParams();
    lp.leftMargin = (int) distanceX;
    lp.rightMargin = -(int) distanceX;
    lastView.setLayoutParams(lp);
    lastView.postInvalidate();
}

但此代码在手机设备中是慢动作。 有什么想法像 setLeft(not work) setRight(not work) 或...? 谢谢!

【问题讨论】:

    标签: android android-view drag


    【解决方案1】:

    看起来这个问题和你的差不多:android drag view smooth

    在列表视图中拖放有点复杂......但是有一个库(https://github.com/bauerca/drag-sort-listview)或者你可以阅读这个拖放教程:http://www.vogella.com/articles/AndroidDragAndDrop/article.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多