是否可以为Android StaggeredGrid
制作拖放方法?
我使用PulseLauncherGrid
进行拖放操作,但当我通过StaggeredGridview
而不是gridview时,它会抛出ClassCastException
。
以下是代码:
private StaggeredGridView grid;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
grid = (StaggeredGridView) findViewById(R.id.grid);
if (getScreenOrientation() == 1)
grid.setNumColumns(3);
else
grid.setNumColumns(4);
items = new ArrayList<LauncherGridItem>();
deleteZone = (DeleteZone) findViewById(R.id.delete_zone_view);
dragLayer = (DragLayer) findViewById(R.id.drag_layer);
adapter = new LauncherGridAdapter(this, items, grid, dragLayer,
deleteZone);
adapter.setPersistenceToken("MyLauncherGrid"); // optional, but if you
adapter.setDragListener(this);