我尝试在网格视图之间拖放项目,项目被正确拖动但在行动时应用程序崩溃。这是我的代码
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());
任何帮助都可以得到赞赏!!