我有3个容器,其中一个包含多个ImageView
,用户可以将其拖放到其他2个容器中。为此,我需要确定哪个getId()
已被删除。我认为img_select
正在做它,但它检索目标容器的Id是有意义的。
在代码中,我使用ImageView
来尝试存储 @Override
public boolean onDrag(View v, DragEvent event) {
int action = event.getAction();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
img_select = v.getId();
break;
case DragEvent.ACTION_DRAG_ENTERED:
v.setBackground(enterShape);
break;
case DragEvent.ACTION_DRAG_EXITED:
v.setBackground(normalShape);
break;
case DragEvent.ACTION_DROP:
// I tried to do it here. I get the id of the container
img_select = v.getId();
View view = (View) event.getLocalState();
ViewGroup owner = (ViewGroup) view.getParent();
owner.removeView(view);
RelativeLayout container = (RelativeLayout) v;
container.addView(view);
view.setVisibility(View.VISIBLE);
break;
case DragEvent.ACTION_DRAG_ENDED:
v.setBackground(normalShape);
default:
break;
}
return true;
}
移动的id的值。如何做的任何例子?
dataset <- read.csv("datasetNA.csv",
sep=";",
header=T,
colClasses="character")
答案 0 :(得分:0)
看起来您正在存储视图父级的ID而不是正在拖动的视图。尝试使用以下ID:
View view = (View) event.getLocalState();
img_select = view.getId()
不要忘记在ACTION_DRAG_STARTED中更改它。