{"id":21083918,"url":"https://github.com/spongebobsun/dndgridview","last_synced_at":"2025-05-16T09:33:38.062Z","repository":{"id":36728840,"uuid":"41035418","full_name":"SpongeBobSun/DNDGridView","owner":"SpongeBobSun","description":"Drag \u0026 Drop GridView for Android","archived":false,"fork":false,"pushed_at":"2017-04-17T02:10:32.000Z","size":1571,"stargazers_count":61,"open_issues_count":0,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T00:41:07.738Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpongeBobSun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-19T13:24:55.000Z","updated_at":"2021-03-29T16:43:28.000Z","dependencies_parsed_at":"2022-07-20T09:53:04.451Z","dependency_job_id":null,"html_url":"https://github.com/SpongeBobSun/DNDGridView","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/SpongeBobSun%2FDNDGridView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpongeBobSun%2FDNDGridView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpongeBobSun%2FDNDGridView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpongeBobSun%2FDNDGridView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpongeBobSun","download_url":"https://codeload.github.com/SpongeBobSun/DNDGridView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225420704,"owners_count":17471629,"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-19T20:20:51.441Z","updated_at":"2024-11-19T20:20:52.062Z","avatar_url":"https://github.com/SpongeBobSun.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DNDGridView\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DNDGridView-green.svg?style=flat)](https://android-arsenal.com/details/1/2385)\n\nDrag \u0026 Drop GridView on Android.\n\n## Poject Components\n\nDNDGridView provide below components.\n\n* DNDGridView, which is a customized GridView.\n* DNDAdapter, most of the drag \u0026 drop part is done in this file.\n* DNDViewHolder, provide ViewHolder which can save current view's position.\n\n## Project Structure\nAfter checkout this repo, you will get a sample project and the DNDGridView module is located in `dndgridview` folder.\n## Usage\n\nTo use DNDGridView, you need to add it in layout xml file or Java code.\n\n\t\u003csun.bob.dndgridview.DNDGridView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1.0\"\n        android:id=\"@+id/id_dndgridview\"/\u003e\n        \nDNDGridView has some restrictions which currently I didn't find a better way to bypass. \n\nFirst, DNDGridView widget only accept DNDAdapter as it's adapter. It will check adapter's type while calling setAdapter. If it's not an instance of DNDAdapter, it will throw a big IllegalArgumentException.\n\nSo, to use drag \u0026 drop feature, you need to extend DNDAdapter using your own adapter. You can using sample project as reference.\n\nIn short word, you must extends DNDAdapter, you MUST implement `getView` function, you MUST call `setUpDragNDrop` after you are done with your item view.\n\n\t\t    ((DNDGridView) findViewById(R.id.id_dndgridview)).setAdapter(new DNDAdapter(this, R.layout.dnd_item) {\n            ArrayList data;\n            {\n                data = new ArrayList();\n                for (int i = 0; i \u003c 100; i++) {\n                    data.add(\"\" + i);\n                }\n                this.setCustomArray(data);\n\n            }\n            @Override\n            public View getView(int posistion, View convertView, ViewGroup parent) {\n                View ret = convertView;\n                ViewHolder tag;\n                if (convertView == null) {\n                    ret = View.inflate(getContext(), R.layout.dnd_item, null);\n                    tag = new ViewHolder(posistion);\n                    tag.imageView = (ImageView) ret.findViewById(R.id.id_imageview);\n                    tag.textView = (TextView) ret.findViewById(R.id.id_textview);\n                    ret.setTag(tag);\n                } else {\n                    tag = (ViewHolder) ret.getTag();\n                }\n                tag.imageView.setImageResource(R.drawable.img0);\n                tag.textView.setText((String) data.get(posistion));\n                setUpDragNDrop(posistion,ret);\n                return ret;\n            }\n        });\n\nSecond, DNDGridView require a DNDViewHolder as view holder. So, if you are using your own viewholder, please extend DNDViewHolder to get this module working. If you didn't specified a view holder, DNDAdapter will automaticlly add one for you.\n\nIn short word, your view holder MUST extends `DNDViewHolder`\n\n\tclass ViewHolder extends DNDViewHolder {\n    \tpublic ViewHolder(int posistion){\n        \tsuper(posistion);\n    \t}\n    \tObject data;\n    \tImageView imageView;\n    \tTextView textView;\n\t}\n\t\n## Screenshot\nPicture file size is 1.6MB so you may want to get yourself a cup of coffee while it's loading.\n![Alt ](./screenshot/shot.gif)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspongebobsun%2Fdndgridview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspongebobsun%2Fdndgridview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspongebobsun%2Fdndgridview/lists"}