本文整理匯總了Java中android.view.DragEvent.ACTION_DRAG_ENTERED屬性的典型用法代碼示例。如果您正苦於以下問題:Java DragEvent.ACTION_DRAG_ENTERED屬性的具體用法?Java DragEvent.ACTION_DRAG_ENTERED怎麽用?Java DragEvent.ACTION_DRAG_ENTERED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.DragEvent
的用法示例。
在下文中一共展示了DragEvent.ACTION_DRAG_ENTERED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setOnDragListener
@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: onDrag
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
switch (dragEvent.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
AttachmentsProvider provider =
AttachmentsProviderFactory.getAttachmentProvider(getContext());
return mCallback != null && provider.isSupported();
case DragEvent.ACTION_DRAG_ENTERED:
setBackgroundColor(ContextCompat.getColor(getContext(), R.color.attachmentOverlay));
return isValidDragEvent(dragEvent.getClipData());
case DragEvent.ACTION_DRAG_ENDED:
setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
return true;
case DragEvent.ACTION_DRAG_EXITED:
case DragEvent.ACTION_DRAG_LOCATION:
return true;
case DragEvent.ACTION_DROP:
if (isValidDragEvent(dragEvent.getClipData())) {
final List<Attachment> attachments = extractAttachments(dragEvent.getClipData());
post(() -> mCallback.onAttachmentsDropped(attachments));
return true;
}
// Fallback
}
return false;
}
示例3: onDragEvent
/**
* Handles drag event.
*/
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// Only handle plain text drag and drop.
return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
case DragEvent.ACTION_DRAG_ENTERED:
requestFocus();
return true;
case DragEvent.ACTION_DROP:
handlePasteClip(event.getClipData());
return true;
}
return false;
}
示例4: handleDragEvent
private boolean handleDragEvent(final View v, final DragEvent event) {
switch(event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
case DragEvent.ACTION_DRAG_ENTERED:
case DragEvent.ACTION_DRAG_LOCATION:
case DragEvent.ACTION_DRAG_EXITED:
case DragEvent.ACTION_DRAG_ENDED:
return true;
case DragEvent.ACTION_DROP:
final String phrase = event.getClipData().getItemAt(0).getText().toString();
moveViewToCorrectLocationFromDrag(v, phrase);
return true;
default:
return false;
}
}
示例5: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
return mEditor != null && mEditor.hasInsertionController();
case DragEvent.ACTION_DRAG_ENTERED:
TextView.this.requestFocus();
return true;
case DragEvent.ACTION_DRAG_LOCATION:
final int offset = getOffsetForPosition(event.getX(), event.getY());
Selection.setSelection((Spannable)mText, offset);
return true;
case DragEvent.ACTION_DROP:
if (mEditor != null) mEditor.onDrop(event);
return true;
case DragEvent.ACTION_DRAG_ENDED:
case DragEvent.ACTION_DRAG_EXITED:
default:
return true;
}
}
示例6: onDrag
public boolean onDrag(View v, DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED:
return dragStart(v, event);
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
return this.dragLocation(v, event);
case DragEvent.ACTION_DRAG_EXITED:
return true;
case DragEvent.ACTION_DROP:
return this.dragDrop(v, event);
case DragEvent.ACTION_DRAG_ENDED:
return true;
default:
Log.e("MarkerDragEventListener", "Unknown action type received by OnDragListener.");
break;
}
return false;
}
示例7: onDrag
@Override
public boolean onDrag (View view, DragEvent event)
{
try
{
switch (event.getAction ())
{
case DragEvent.ACTION_DRAG_ENTERED:
this.appManager.startedDraggingPinnedApp ();
break;
case DragEvent.ACTION_DROP:
case DragEvent.ACTION_DRAG_EXITED:
this.appManager.stoppedDraggingPinnedApp ();
break;
}
}
catch (Exception ex)
{
ExceptionHandler exh = new ExceptionHandler (this.appManager.getContext (), ex);
exh.show ();
}
return true;
}
示例8: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//Log.i(TAG, "Drag Started.");
return onDragStarted(event);
case DragEvent.ACTION_DRAG_ENTERED:
Log.i(TAG, "Drag entered ADDV");
return onDragEntered(event);
case DragEvent.ACTION_DRAG_LOCATION:
return onDragMoveOn(event);
case DragEvent.ACTION_DRAG_EXITED:
Log.i(TAG, "Drag exited ADDV");
return onDragExited(event);
case DragEvent.ACTION_DROP:
Log.i(TAG, "Drag droped ADDV");
return onDrop(event);
case DragEvent.ACTION_DRAG_ENDED:
//Log.i(TAG, "Drag ended ADDV.");
return onDragEnded(event);
}
return super.onDragEvent(event);
}
示例9: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//Log.i(TAG, "DropLV Drag Started.");
return onDragStarted(event);
case DragEvent.ACTION_DRAG_ENTERED:
Log.i(TAG, "Drag entered DropLV.");
return onDragEntered(event);
case DragEvent.ACTION_DRAG_LOCATION:
return onDragMoveOn(event);
case DragEvent.ACTION_DRAG_EXITED:
Log.i(TAG, "Drag exited DropLV.");
return onDragExited(event);
case DragEvent.ACTION_DROP:
Log.i(TAG, "Drag droped DropLV.");
return onDrop(event);
case DragEvent.ACTION_DRAG_ENDED:
//Log.i(TAG, "DropLV Drag ended.");
return onDragEnded(event);
}
return super.onDragEvent(event);
}
示例10: onDragEvent
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
//Log.i(TAG, "DropGV Drag Started.");
return onDragStarted(event);
case DragEvent.ACTION_DRAG_ENTERED:
Log.i(TAG, "Drag entered DropGV.");
return onDragEntered(event);
case DragEvent.ACTION_DRAG_LOCATION:
return onDragMoveOn(event);
case DragEvent.ACTION_DRAG_EXITED:
Log.i(TAG, "Drag exited DropGV");
return onDragExited(event);
case DragEvent.ACTION_DROP:
Log.i(TAG, "Drag droped DropGV");
return onDrop(event);
case DragEvent.ACTION_DRAG_ENDED:
//Log.i(TAG, "Drag ended DropGV.");
return onDragEnded(event);
}
return super.onDragEvent(event);
}
示例11: onDragEvent
@Override
public boolean onDragEvent (DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED:
mLastX = event.getX();
mLastY = event.getY();
return true;
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
mLastX = event.getX();
mLastY = event.getY();
mEventListener.onDriverDragMove(event.getX(), event.getY());
return true;
case DragEvent.ACTION_DROP:
mLastX = event.getX();
mLastY = event.getY();
mEventListener.onDriverDragMove(event.getX(), event.getY());
mEventListener.onDriverDragEnd(mLastX, mLastY);
return true;
case DragEvent.ACTION_DRAG_EXITED:
mEventListener.onDriverDragExitWindow();
return true;
case DragEvent.ACTION_DRAG_ENDED:
mEventListener.onDriverDragCancel();
return true;
default:
return false;
}
}
示例12: onDrag
public boolean onDrag(View v, DragEvent event) {
int action = event.getAction();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
v.setBackgroundColor(LIGHT_BLUE);
v.invalidate();
return true;
case DragEvent.ACTION_DRAG_ENTERED:
v.setBackgroundColor(LIGHT_GREEN);
v.invalidate();
return true;
case DragEvent.ACTION_DRAG_EXITED:
v.setBackgroundColor(LIGHT_BLUE);
v.invalidate();
return true;
case DragEvent.ACTION_DRAG_ENDED:
v.setBackgroundColor(Color.WHITE);
v.invalidate();
return true;
case DragEvent.ACTION_DROP:
// Dropped, reassign Tile to the target Layout
LetterTile tile = (LetterTile) event.getLocalState();
tile.moveToViewGroup((ViewGroup) v);
if (stackedLayout.empty()) {
TextView messageBox = (TextView) findViewById(R.id.message_box);
messageBox.setText(word1 + " " + word2);
}
/**
**
** YOUR CODE GOES HERE
**
**/
return true;
}
return false;
}
示例13: onDrag
@Override
public boolean onDrag(View v, DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// Do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
v.setAlpha(0.5F);
break;
case DragEvent.ACTION_DRAG_EXITED:
v.setAlpha(1F);
break;
case DragEvent.ACTION_DROP:
View view = (View) event.getLocalState();
View item = (View) view.getParent().getParent();
for (int i = 0, j = videosScroll.getChildCount(); i < j; i++) {
if (videosScroll.getChildAt(i).findViewById(R.id.editor_image) == v) {
// 當前位置
videosScroll.removeView(item);
videosScroll.addView(item, i);
break;
}
}
RefreshVideosScroll(true);
break;
case DragEvent.ACTION_DRAG_ENDED:
v.setAlpha(1F);
default:
break;
}
return true;
}
示例14: onDrag
@Override
public boolean onDrag(View v, DragEvent event) {
switch(event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
onDropListener.onDragStarted();
return true;
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
// Ignore the event
onDropListener.onDragLocation(event.getX(), event.getY());
return true;
case DragEvent.ACTION_DRAG_EXITED:
return true;
case DragEvent.ACTION_DROP:
onDropListener.onDrop();
return true;
case DragEvent.ACTION_DRAG_ENDED:
onDropListener.onDragEnded();
return true;
default:
break;
}
return false;
}
示例15: onDrag
@Override
public boolean onDrag(View v, DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED: // 拖拽開始
Log.i("拖拽事件", "拖拽開始");
return event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
case DragEvent.ACTION_DRAG_ENTERED: // 被拖拽View進入目標區域
Log.i("拖拽事件", "被拖拽View進入目標區域");
return true;
case DragEvent.ACTION_DRAG_LOCATION: // 被拖拽View在目標區域移動
Log.i("拖拽事件", "被拖拽View在目標區域移動___X:" + event.getX() + "___Y:" + event.getY());
tvTip.setText("X:" + event.getX() + " Y:" + event.getY());
return true;
case DragEvent.ACTION_DRAG_EXITED: // 被拖拽View離開目標區域
Log.i("拖拽事件", "被拖拽View離開目標區域");
return true;
case DragEvent.ACTION_DROP: // 放開被拖拽View
Log.i("拖拽事件", "放開被拖拽View");
// 釋放拖拽陰影,並獲取移動數據
ClipData.Item item = event.getClipData().getItemAt(0);
String content = item.getText().toString();
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
return true;
case DragEvent.ACTION_DRAG_ENDED: // 拖拽完成
Log.i("拖拽事件", "拖拽完成");
return true;
default:
break;
}
return false;
}