本文整理汇总了Java中android.view.View.OnDragListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.OnDragListener方法的具体用法?Java View.OnDragListener怎么用?Java View.OnDragListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.OnDragListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOnDragListener
import android.view.View; //导入方法依赖的package包/类
@Override
public void setOnDragListener(final View.OnDragListener dragListener) {
View.OnDragListener wrapper = new OnDragListener() {
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
int action = dragEvent.getAction();
// Whether the dragged object can be handled by the trash.
boolean result = dragListener.onDrag(view, dragEvent);
if (action == DragEvent.ACTION_DRAG_ENDED) {
setState(STATE_DEFAULT);
} else if (result) {
switch (action) {
case DragEvent.ACTION_DRAG_ENTERED:
setState(STATE_ON_HOVER);
break;
case DragEvent.ACTION_DROP:
case DragEvent.ACTION_DRAG_EXITED:
setState(STATE_DEFAULT);
break;
}
}
return result;
}
};
super.setOnDragListener(wrapper);
}
示例2: QuickRow
import android.view.View; //导入方法依赖的package包/类
public QuickRow(final View.OnDragListener dragListener, MainActivity mainActivity) {
mMainActivity = mainActivity;
mQuickRow = mMainActivity.findViewById(R.id.layout_quickrow);
mQuickRowScroller = mMainActivity.findViewById(R.id.layout_quickrow_scroll);
mQuickRow.setOnDragListener(dragListener);
mQuickRowScroller.setOnDragListener(new View.OnDragListener() {
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
return dragListener.onDrag(mQuickRow, dragEvent);
}
});
}
示例3: getDragEventListener
import android.view.View; //导入方法依赖的package包/类
/**
* @return The listener to use for {@link DragEvent}'s in the {@link WorkspaceView}.
*/
public View.OnDragListener getDragEventListener() {
return mDragEventListener;
}
示例4: initiliazeInternalListener
import android.view.View; //导入方法依赖的package包/类
private void initiliazeInternalListener() {
mInternalDragListener = new View.OnDragListener() {
@Override
public boolean onDrag(View v, DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// check if listener could catch this event.
ClipDescription description = event.getClipDescription();
if (description == null) {
return false;
}
String className = String.valueOf(description.getLabel());
if (mDraggedItem == null && mHandledClassNames.contains(className)) {
// retrieve the data object linked to the dragged event.
mDraggedItem = DragHelper.getDraggedItem(((Integer) event.getLocalState()));
onDragStarted(mDraggedItem.getSource(), mDraggedItem.getData());
return true;
} else {
return false;
}
case DragEvent.ACTION_DRAG_ENTERED:
onDragEntered(mDraggedItem.getSource(), mDraggedItem.getData());
break;
case DragEvent.ACTION_DRAG_LOCATION:
onDragLocation(
mDraggedItem.getSource(), mDraggedItem.getData(),
event.getX(), event.getY()
);
break;
case DragEvent.ACTION_DROP:
onDragDropped(
mDraggedItem.getSource(), mDraggedItem.getData(),
event.getX(), event.getY()
);
break;
case DragEvent.ACTION_DRAG_EXITED:
onDragExited(mDraggedItem.getSource(), mDraggedItem.getData());
break;
case DragEvent.ACTION_DRAG_ENDED:
if (mDraggedItem != null) {
onDragEnded(mDraggedItem.getSource(), mDraggedItem.getData());
DragHelper.clearDraggedItem(mDraggedItem.getToken());
mDraggedItem = null;
}
break;
default:
break;
}
return true;
}
};
}
示例5: getInternalDragListener
import android.view.View; //导入方法依赖的package包/类
/**
* Retrieve the internal drag listener.
*
* @return internal drag listener.
*/
View.OnDragListener getInternalDragListener() {
return mInternalDragListener;
}
示例6: setOnDragListener
import android.view.View; //导入方法依赖的package包/类
/**
* Delegiert von android.widget.Button
*
* @param l siehe {@link Button}
*/
public void setOnDragListener(View.OnDragListener l) {
b.setOnDragListener(l);
}