Bilibili/DynamicGrid

Name: DynamicGrid

Owner: bilibili

Description: Drag and drop GridView for Android

Created: 2015-03-26 02:27:00.0

Updated: 2018-03-12 20:05:48.0

Pushed: 2015-03-26 04:18:17.0

Homepage: null

Size: 348

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

DynamicGrid

Drag and drop GridView for Android.

Demo

example

Requirements

Rearranging items require api 8 (Froyo). All grid item animations require api 11 (Honeycomb).

Usage

All the same as for normal GridView. Adapter must extends AbstractDynamicGridAdapter or BaseDynamicGridAdapter

View = (DynamicGridView) findViewById(R.id.dynamic_grid);
ass to adapter context, list of items and number of columns count
View.setAdapter(new MyDynamicGridAdapter(this, itemsList, 3));

To start Drag'n'drop mode:

View.startEditMode();

Or from onItemClik() and onItemLongClick()

View.startEditMode(position);

To stop:

View.stopEditMode();

Adding drop listener:

View.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.

Credits

DynamicGridView based on Daniel Olshansky ListView cell dragging and rearranging example.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.