当我将项目放入gridview时,Android应用程序崩溃

时间:2016-04-19 07:55:28

标签: android gridview drag-and-drop

我尝试在网格视图之间拖放项目,项目被正确拖动但在行动时应用程序崩溃。这是我的代码

 case DragEvent.ACTION_DROP:

                    PassObject passObj = (PassObject)event.getLocalState();
                    View view = passObj.view;
                    Artifact passedItem = passObj.artifact;
                    List<Artifact> srcList = passObj.srcList;
                    AbsListView oldParent = (AbsListView)view.getParent();
                    ArtifactAdapter srcAdapter = (ArtifactAdapter) oldParent.getAdapter();

                    LinearLayoutAbsListView newParent = (LinearLayoutAbsListView)v;
                    ArtifactAdapter destAdapter = (ArtifactAdapter)(newParent.absListView.getAdapter());
                    List<Artifact> destList = destAdapter.getList();

                    if(removeItemToList(srcList, passedItem)){
                        addItemToList(destList, passedItem);
                    }

                    srcAdapter.notifyDataSetChanged();
                    destAdapter.notifyDataSetChanged();

                    //smooth scroll to bottom
                    newParent.absListView.smoothScrollToPosition(destAdapter.getCount()-1);

                    break;
                case DragEvent.ACTION_DRAG_ENDED:
                default:
                    break;

问题在于这一行

ArtifactAdapter destAdapter = (ArtifactAdapter)(newParent.absListView.getAdapter());

任何帮助都可以得到赞赏!!

0 个答案:

没有答案