https://github.com/askerov/DynamicGridの動くバージョンです
.gradle | 5 years ago | ||
dynamicgrid | 5 years ago | ||
example | 5 years ago | ||
gradle/ wrapper | 5 years ago | ||
.gitignore | 5 years ago | ||
LICENSE | 5 years ago | ||
README.md | 5 years ago | ||
build.gradle | 5 years ago | ||
gradlew | 5 years ago | ||
gradlew.bat | 5 years ago | ||
settings.gradle | 5 years ago |
Drag and drop GridView for Android.
It's much better to use solutions based on recycler view. For example https://github.com/h6ah4i/android-advancedrecyclerview
Rearranging items require api 8 (Froyo). All grid item animations require api 11 (Honeycomb).
All the same as for normal GridView. Adapter must extends AbstractDynamicGridAdapter or BaseDynamicGridAdapter
gridView = (DynamicGridView) findViewById(R.id.dynamic_grid); // pass to adapter context, list of items and number of columns count gridView.setAdapter(new MyDynamicGridAdapter(this, itemsList, 3));
To start Drag'n'drop mode:
gridView.startEditMode();
Or from onItemClik() and onItemLongClick()
gridView.startEditMode(position);
To stop:
gridView.stopEditMode();
Adding drop listener:
gridView.setOnDropListener(new DynamicGridView.OnDropListener(){ @Override public void onActionDrop(){ // stop edit mode immediately after drop item gridView.stopEditMode(); } });
You can find more detailed usage example here.
DynamicGridView based on Daniel Olshansky ListView cell dragging and rearranging example.