Android StaggeredGrid的拖放方法

时间:2013-12-22 12:22:40

标签: android

是否可以为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);

0 个答案:

没有答案