【发布时间】:2012-10-11 19:35:10
【问题描述】:
我一直在使用拖放功能编写一个简单的应用程序,效果很好,除了一些细节。当我第一次持有包含拖动操作的 ImageView 时,DragShadowBuilder 将微型视图放置在错误的位置。最奇怪的是,后来它自己修复了,并且运行得很好。 这是一张显示行为的图片(我拿着通讯录应用图标,看看缩略图在哪里)
这是我使用的代码
View v = inflater.inflate(R.layout.recent_entry, null);
ImageView img = (ImageView)v.findViewById(R.id.recent_icon);
img.setOnTouchListener(new View.OnTouchListener(){
@Override
public boolean onTouch(View view, MotionEvent me) {
if (me.getAction() == MotionEvent.ACTION_DOWN){
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(null, shadowBuilder, null, 0);
mLaunchIntent = holder.getLaunchIntent();
mSelectedItem = view;
mRecentDetails.setVisibility(View.GONE);
}
return true;
}
});
【问题讨论】:
标签: java android drag-and-drop imageview