{"id":21130165,"url":"https://github.com/terlici/DragNDropList","last_synced_at":"2025-07-09T01:32:36.487Z","repository":{"id":5376167,"uuid":"6563465","full_name":"terlici/DragNDropList","owner":"terlici","description":"An easy to use Drag \u0026 Drop List for Android. Direct replacement of the android ListView.","archived":false,"fork":false,"pushed_at":"2016-05-24T14:39:19.000Z","size":1524,"stargazers_count":186,"open_issues_count":10,"forks_count":68,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-04-14T07:18:38.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terlici.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-06T14:34:37.000Z","updated_at":"2023-09-08T16:36:06.000Z","dependencies_parsed_at":"2022-09-23T22:10:15.902Z","dependency_job_id":null,"html_url":"https://github.com/terlici/DragNDropList","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terlici%2FDragNDropList","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terlici%2FDragNDropList/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terlici%2FDragNDropList/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terlici%2FDragNDropList/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terlici","download_url":"https://codeload.github.com/terlici/DragNDropList/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476373,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T05:32:20.649Z","updated_at":"2024-11-20T05:32:28.970Z","avatar_url":"https://github.com/terlici.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# DragNDropListView\nDragNDropListView is a direct replacement for the stock Android ListView. If you know how to use ListView, you already know how to use DragNDropListView. All you have to do is replace ListView and SimpleCursorAdapter/SimpleAdapter with DragNDropListView and its adapters.\n\n# Usage\nDragNDropListView is an Android Library project. If you use Eclipse do the following.\n* Clone `git clone git://github.com/terlici/DragNDropList.git`\n* Import it in Eclipse\n* Add DragNDropList as a library to your Android project\n\n### Layout\n\nA common layout for list view is the following:\n\n````xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\u003e\n\n    \u003cListView\n        android:id=\"@id/android:list\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        /\u003e\n\n\u003c/LinearLayout\u003e\n````\n\nJust replace `ListView` with `com.terlici.dragndroplist.DragNDropListView`:\n\n````xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\u003e\n\n    \u003ccom.terlici.dragndroplist.DragNDropListView\n        android:id=\"@id/android:list\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        /\u003e\n\n\u003c/LinearLayout\u003e\n````\n\n### Row Layout\nIn DragNDropListView each item has a drag handler, which the users touch to drag the item around.\n\nHere is a common layout for each row. It contains an image of a star and some text.\nThe user can reorder the items by touching the star of an item and dragging it around.\n\n````xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"80px\"\n    android:orientation=\"horizontal\"\n    android:gravity=\"center_vertical\"\n    \u003e\n\n    \u003cImageView\n        android:id=\"@+id/handler\"\n        android:layout_width=\"60px\"\n        android:layout_height=\"60px\"\n        android:src=\"@android:drawable/btn_star_big_on\"\n        android:layout_marginLeft=\"8px\"\n        /\u003e\n\n    \u003cTextView\n        android:id=\"@+id/text\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Large Text\"\n        android:textAppearance=\"?android:attr/textAppearanceLarge\" /\u003e\n\n\u003c/LinearLayout\u003e\n````\n\n### Loading DragNDropListView\n\nThis is the usual way to load a ListView:\n\n````java\nListView list = (ListView)findViewById(android.R.id.list);\n\nSimpleCursorAdapter adapter = new SimpleCursorAdapter(context,\n                        R.layout.row,\n                        cursor,\n                        new String[]{\"text\"},\n                        new int[]{R.id.text},\n                        0);\n\nlist.setListAdapter(adapter);\n````\n\nWhen using DragNDropListView just replace `ListView` with `DragNDropListView`,\n`SimpleCursorAdapter` with `DragNDropCursorAdapter` and set the id of the drag\nhandler as the last parameter of the adapter. In the row layout above this will\nbe `R.id.handler`. Last, instead of `setListAdapter` use `setDragNDropAdapter`.\n\n````java\nDragNDropListView list = (DragNDropListView)findViewById(android.R.id.list);\n\nDragNDropCursorAdapter adapter = new DragNDropCursorAdapter(context,\n                           R.layout.row,\n                           cursor,\n                           new String[]{\"text\"},\n                           new int[]{R.id.text},\n                           R.id.handler);\n\nlist.setDragNDropAdapter(adapter);\n````\n\nYou are done! As you see there is very little to change to your existing code.\n\n### Events\nDragNDropListView provides an event listener for drag and drop.\n\n````java\nlist.setOnItemDragNDropListener(...)\n````\n\nThe interface for this listener is:\n\n````java\npublic interface OnItemDragNDropListener {\n    // Called when the item begins dragging.\n    public void onItemDrag(DragNDropListView parent, View view, int position, long id);\n\n    // Called after the item is dropped in place\n    public void onItemDrop(DragNDropListView parent, View view, int startPosition, int endPosition, long id);\n}\n````\n\nThis event is useful when storing the reordered items.\n\n### Adapters\n\nDragNDropList comes with two adapters. The first one is `DragNDropCursorAdapter`\nwhich is a direct replacement for `SimpleCursorAdapter`. The second is `DragNDropSimpleAdapter`\nwhich is a replacement for `SimpleAdapter`.\n\n# Apps that use DragNDropList\nDragNDropList was originally created for our apps [Tasks](http://play.google.com/store/apps/details?id=com.vnsndev.tasks) and\n[Tasks Pro](http://play.google.com/store/apps/details?id=com.vnsndev.taskspro). Download one of them to see it in action.\n\nIf other apps use it, please let us know and we will include them here.\n\n# Contribution\nIf you want to contribute, there are two more projects. [DragNDropListApp](https://github.com/terlici/DragNDropListApp) implements a basic demo of the DragNDropList. [DragNDropListAppTest](https://github.com/terlici/DragNDropListAppTest) runs tests on the DragNDropListApp and contains all the tests for the DragNDropList.\n\nIf you want to contribute, please fork also those two projects and add your tests to DragNDropListAppTest.\n\n# License\n\n`DragNDropList`'s code uses the Apache license, see our `LICENSE` file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterlici%2FDragNDropList","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterlici%2FDragNDropList","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterlici%2FDragNDropList/lists"}