或者滚动的水平列表(选项B):
让我们暂时假设选项A是相关的,所以你需要:
>水平清单实施
>适当的拖放处理
步骤1
有几个水平列表实现可用,但其中一些是旧的,不支持,所以我建议检查Horizontal Variable ListView:
Horizontal ListVIEw for AndroID. Based on the official ListVIEw Google
code. It supports almost all the features of the ListVIEw Widget.
There are minor differences in the attributes supported like
“divIDerWIDth” instead of the default “divIDerHeight”.
BTW它支持AndroID 4.2.2,另请参阅demo example.
第2步
此时您实际需要的只是正确处理拖放 *** 作.
最简单的解决方案是遵循音乐应用程序中使用的标准和众所周知的示例:TouchInterceptor class.它扩展了ListVIEw,因此使用与Horizontal Variable ListView相同的方法应该不会有问题.
特别注意:
public boolean onIntercepttouchEvent(MotionEvent ev) {
和
public boolean ontouchEvent(MotionEvent ev) {
第3步:高级实施
我个人认为选项A只能用作演示,所以你必须解决滚动问题.上面的示例显示了如何处理滚动,但可能需要更多一些.
还有另一个项目(再次停产)可用作高级示例,因为它解决了几个问题,支持动画等:
07004 is an extension of the AndroID ListVIEw that
Clean drag and drop Intuitive and smooth scrolling while dragging. Support for heterogeneous item heights. Public startDrag() and stopDrag() methods. Public interface for customizing the floating VIEw.
enables drag-and-drop reordering of List items. It is a major overhaul
complete rewrite of the touchInterceptor (TI) meant to give
drag-sorting a polished feel. Some key features are:DragSortListVIEw is useful for all kinds of prioritized Lists:
favorites,playLists,checkLists,etc.
它似乎记录良好且易于理解.从垂直模式切换到水平模式不应该那么难.
public class DragSortListVIEw extends ListVIEw { /** * The VIEw that floats above the ListVIEw and represents * the dragged item. */ private VIEw mfloatVIEw; /** * The float VIEw location. First based on touch location * and given deltaX and deltaY. Then restricted by callback * to floatVIEwManager.onDragfloatVIEw(). Finally restricted * by bounds of DSLV. */ private Point mfloatLoc = new Point(); private Point mtouchLoc = new Point(); /** * The mIDdle (in the y-direction) of the floating VIEw. */ private int mfloatVIEwMID; /** * Flag to make sure float VIEw isn't measured twice */ private boolean mfloatVIEwOnMeasured = false; /** * Watch the Adapter for data changes. Cancel a drag if * coincIDent with a change. */ private DataSetobserver mObserver; /** * Transparency for the floating VIEw (XML attribute). */ private float mfloatAlpha = 1.0f; private float mCurrfloatAlpha = 1.0f; /** * While drag-sorting,the current position of the floating * VIEw. If dropped,the dragged item will land in this position. */ private int mfloatPos;总结
以上是内存溢出为你收集整理的Android控件用于简单的拖放框全部内容,希望文章能够帮你解决Android控件用于简单的拖放框所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)