本文整理汇总了C#中android.getAction方法的典型用法代码示例。如果您正苦于以下问题:C# android.getAction方法的具体用法?C# android.getAction怎么用?C# android.getAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android
的用法示例。
在下文中一共展示了android.getAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onTouchEvent
public override bool onTouchEvent(android.view.MotionEvent @event)
{
if ((@event.getAction() == android.view.MotionEvent.ACTION_CANCEL) || (@event.getAction
() == android.view.MotionEvent.ACTION_UP))
{
mIsInLongpress = false;
}
return base.onTouchEvent(@event);
}
示例2: onKeyOther
public virtual bool onKeyOther(android.widget.TextView widget, android.text.Spannable
text, android.view.KeyEvent @event)
{
int movementMetaState = getMovementMetaState(text, @event);
int keyCode = @event.getKeyCode();
if (keyCode != android.view.KeyEvent.KEYCODE_UNKNOWN && @event.getAction() == android.view.KeyEvent
.ACTION_MULTIPLE)
{
int repeat = @event.getRepeatCount();
bool handled = false;
{
for (int i = 0; i < repeat; i++)
{
if (!handleMovementKey(widget, text, keyCode, movementMetaState, @event))
{
break;
}
handled = true;
}
}
if (handled)
{
android.text.method.MetaKeyKeyListener.adjustMetaAfterKeypress(text);
android.text.method.MetaKeyKeyListener.resetLockedMeta(text);
}
return handled;
}
return false;
}
示例3: onReceive
public override void onReceive(android.content.Context context, android.content.Intent
intent)
{
// BEGIN_INCLUDE(onReceive)
// Protect against rogue update broadcasts (not really a security issue,
// just filter bad broacasts out so subclasses are less likely to crash).
string action = intent.getAction();
if (android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE.Equals(action))
{
android.os.Bundle extras = intent.getExtras();
if (extras != null)
{
int[] appWidgetIds = extras.getIntArray(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_IDS
);
if (appWidgetIds != null && appWidgetIds.Length > 0)
{
this.onUpdate(context, android.appwidget.AppWidgetManager.getInstance(context), appWidgetIds
);
}
}
}
else
{
if (android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DELETED.Equals(action))
{
android.os.Bundle extras = intent.getExtras();
if (extras != null && extras.containsKey(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID
))
{
int appWidgetId = extras.getInt(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID
);
this.onDeleted(context, new int[] { appWidgetId });
}
}
else
{
if (android.appwidget.AppWidgetManager.ACTION_APPWIDGET_ENABLED.Equals(action))
{
this.onEnabled(context);
}
else
{
if (android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DISABLED.Equals(action))
{
this.onDisabled(context);
}
}
}
}
}
示例4: onKey
public virtual bool onKey(android.content.DialogInterface dialog, int keyCode, android.view.KeyEvent
@event)
{
if (keyCode == android.view.KeyEvent.KEYCODE_MENU || keyCode == android.view.KeyEvent
.KEYCODE_BACK)
{
if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
() == 0)
{
android.view.Window win = mDialog.getWindow();
if (win != null)
{
android.view.View decor = win.getDecorView();
if (decor != null)
{
android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
if (ds != null)
{
ds.startTracking(@event, this);
return true;
}
}
}
}
else
{
if (@event.getAction() == android.view.KeyEvent.ACTION_UP && [email protected]())
{
android.view.Window win = mDialog.getWindow();
if (win != null)
{
android.view.View decor = win.getDecorView();
if (decor != null)
{
android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
if (ds != null && ds.isTracking(@event))
{
mMenu.close(true);
dialog.dismiss();
return true;
}
}
}
}
}
}
// Menu shortcut matching
return mMenu.performShortcut(keyCode, @event, 0);
}
示例5: onReceive
public override void onReceive(android.content.Context context, android.content.Intent
intent)
{
string action = intent.getAction();
if (android.content.Intent.ACTION_SCREEN_OFF.Equals(action))
{
this._enclosing.mUserPresent = false;
this._enclosing.updateRunning();
}
else
{
if (android.content.Intent.ACTION_USER_PRESENT.Equals(action))
{
this._enclosing.mUserPresent = true;
this._enclosing.updateRunning(false);
}
}
}
示例6: handleMovementKey
protected internal override bool handleMovementKey(android.widget.TextView widget
, android.text.Spannable buffer, int keyCode, int movementMetaState, android.view.KeyEvent
@event)
{
switch (keyCode)
{
case android.view.KeyEvent.KEYCODE_DPAD_CENTER:
{
if (android.view.KeyEvent.metaStateHasNoModifiers(movementMetaState))
{
if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
() == 0 && android.text.method.MetaKeyKeyListener.getMetaState(buffer, android.text.method.MetaKeyKeyListener
.META_SELECTING) != 0)
{
return widget.showContextMenu();
}
}
break;
}
}
return base.handleMovementKey(widget, buffer, keyCode, movementMetaState, @event);
}
示例7: onContainerKey
private bool onContainerKey(android.view.KeyEvent @event)
{
int keyCode = @event.getKeyCode();
if (isInterestingKey(keyCode))
{
if (keyCode == android.view.KeyEvent.KEYCODE_BACK)
{
if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
() == 0)
{
if (mOwnerView != null)
{
android.view.KeyEvent.DispatcherState ds = mOwnerView.getKeyDispatcherState();
if (ds != null)
{
ds.startTracking(@event, this);
}
}
return true;
}
else
{
if (@event.getAction() == android.view.KeyEvent.ACTION_UP && @event.isTracking()
&& [email protected]())
{
setVisible(false);
return true;
}
}
}
else
{
dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
}
// Let the container handle the key
return false;
}
else
{
android.view.ViewRootImpl viewRoot = getOwnerViewRootImpl();
if (viewRoot != null)
{
viewRoot.dispatchKey(@event);
}
// We gave the key to the owner, don't let the container handle this key
return true;
}
}
示例8: dispatchTransformedTouchEvent
/// <summary>
/// Transforms a motion event into the coordinate space of a particular child view,
/// filters out irrelevant pointer ids, and overrides its action if necessary.
/// </summary>
/// <remarks>
/// Transforms a motion event into the coordinate space of a particular child view,
/// filters out irrelevant pointer ids, and overrides its action if necessary.
/// If child is null, assumes the MotionEvent will be sent to this ViewGroup instead.
/// </remarks>
private bool dispatchTransformedTouchEvent(android.view.MotionEvent @event, bool
cancel, android.view.View child, int desiredPointerIdBits)
{
bool handled;
// Canceling motions is a special case. We don't need to perform any transformations
// or filtering. The important part is the action, not the contents.
int oldAction = @event.getAction();
if (cancel || oldAction == android.view.MotionEvent.ACTION_CANCEL)
{
@event.setAction(android.view.MotionEvent.ACTION_CANCEL);
if (child == null)
{
handled = base.dispatchTouchEvent(@event);
}
else
{
handled = child.dispatchTouchEvent(@event);
}
@event.setAction(oldAction);
return handled;
}
// Calculate the number of pointers to deliver.
int oldPointerIdBits = @event.getPointerIdBits();
int newPointerIdBits = oldPointerIdBits & desiredPointerIdBits;
// If for some reason we ended up in an inconsistent state where it looks like we
// might produce a motion event with no pointers in it, then drop the event.
if (newPointerIdBits == 0)
{
return false;
}
// If the number of pointers is the same and we don't need to perform any fancy
// irreversible transformations, then we can reuse the motion event for this
// dispatch as long as we are careful to revert any changes we make.
// Otherwise we need to make a copy.
android.view.MotionEvent transformedEvent;
if (newPointerIdBits == oldPointerIdBits)
{
if (child == null || child.hasIdentityMatrix())
{
if (child == null)
{
handled = base.dispatchTouchEvent(@event);
}
else
{
float offsetX = mScrollX - child.mLeft;
float offsetY = mScrollY - child.mTop;
@event.offsetLocation(offsetX, offsetY);
handled = child.dispatchTouchEvent(@event);
@event.offsetLocation(-offsetX, -offsetY);
}
return handled;
}
transformedEvent = android.view.MotionEvent.obtain(@event);
}
else
{
transformedEvent = @event.split(newPointerIdBits);
}
// Perform any necessary transformations and dispatch.
if (child == null)
{
handled = base.dispatchTouchEvent(transformedEvent);
}
else
{
float offsetX = mScrollX - child.mLeft;
float offsetY = mScrollY - child.mTop;
transformedEvent.offsetLocation(offsetX, offsetY);
if (!child.hasIdentityMatrix())
{
transformedEvent.transform(child.getInverseMatrix());
}
handled = child.dispatchTouchEvent(transformedEvent);
}
// Done.
transformedEvent.recycle();
return handled;
}
示例9: onReceive
public override void onReceive(android.content.Context context, android.content.Intent
intent)
{
if (intent.getAction().Equals(android.content.Intent.ACTION_TIMEZONE_CHANGED))
{
string tz = intent.getStringExtra("time-zone");
this._enclosing.mCalendar = new android.text.format.Time(java.util.TimeZone.getTimeZone
(tz).getID());
}
this._enclosing.onTimeChanged();
this._enclosing.invalidate();
}
示例10: onTouchEvent
public override bool onTouchEvent(android.view.MotionEvent @event)
{
if (!mIsUserSeekable || !isEnabled())
{
return false;
}
switch (@event.getAction())
{
case android.view.MotionEvent.ACTION_DOWN:
{
if (isInScrollingContainer())
{
mTouchDownX = @event.getX();
}
else
{
setPressed(true);
if (mThumb != null)
{
invalidate(mThumb.getBounds());
}
// This may be within the padding region
onStartTrackingTouch();
trackTouchEvent(@event);
attemptClaimDrag();
}
break;
}
case android.view.MotionEvent.ACTION_MOVE:
{
if (mIsDragging)
{
trackTouchEvent(@event);
}
else
{
float x = @event.getX();
if (System.Math.Abs(x - mTouchDownX) > mScaledTouchSlop)
{
setPressed(true);
if (mThumb != null)
{
invalidate(mThumb.getBounds());
}
// This may be within the padding region
onStartTrackingTouch();
trackTouchEvent(@event);
attemptClaimDrag();
}
}
break;
}
case android.view.MotionEvent.ACTION_UP:
{
if (mIsDragging)
{
trackTouchEvent(@event);
onStopTrackingTouch();
setPressed(false);
}
else
{
// Touch up when we never crossed the touch slop threshold should
// be interpreted as a tap-seek to that location.
onStartTrackingTouch();
trackTouchEvent(@event);
onStopTrackingTouch();
}
// ProgressBar doesn't know to repaint the thumb drawable
// in its inactive state when the touch stops (because the
// value has not apparently changed)
invalidate();
break;
}
case android.view.MotionEvent.ACTION_CANCEL:
{
if (mIsDragging)
{
onStopTrackingTouch();
setPressed(false);
}
invalidate();
// see above explanation
break;
}
}
return true;
}
示例11: dispatchKeyEvent
public override bool dispatchKeyEvent(android.view.KeyEvent @event)
{
if (@event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK)
{
if (this.getKeyDispatcherState() == null)
{
return base.dispatchKeyEvent(@event);
}
if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
() == 0)
{
android.view.KeyEvent.DispatcherState state = this.getKeyDispatcherState();
if (state != null)
{
state.startTracking(@event, this);
}
return true;
}
else
{
if (@event.getAction() == android.view.KeyEvent.ACTION_UP)
{
android.view.KeyEvent.DispatcherState state = this.getKeyDispatcherState();
if (state != null && state.isTracking(@event) && [email protected]())
{
this._enclosing.dismiss();
return true;
}
}
}
return base.dispatchKeyEvent(@event);
}
else
{
return base.dispatchKeyEvent(@event);
}
}
示例12: onKeyPreIme
/// <summary>Filter pre-IME key events.</summary>
/// <remarks>
/// Filter pre-IME key events. By forwarding
/// <see cref="android.view.View.onKeyPreIme(int, android.view.KeyEvent)">android.view.View.onKeyPreIme(int, android.view.KeyEvent)
/// </see>
/// events to this function, views using ListPopupWindow can have it dismiss the popup
/// when the back key is pressed.
/// </remarks>
/// <param name="keyCode">keyCode param passed to the host view's onKeyPreIme</param>
/// <param name="event">event param passed to the host view's onKeyPreIme</param>
/// <returns>true if the event was handled, false if it was ignored.</returns>
/// <seealso cref="setModal(bool)">setModal(bool)</seealso>
public virtual bool onKeyPreIme(int keyCode, android.view.KeyEvent @event)
{
if (keyCode == android.view.KeyEvent.KEYCODE_BACK && isShowing())
{
// special case for the back key, we do not even try to send it
// to the drop down list but instead, consume it immediately
android.view.View anchorView = mDropDownAnchorView;
if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
() == 0)
{
android.view.KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState();
if (state != null)
{
state.startTracking(@event, this);
}
return true;
}
else
{
if (@event.getAction() == android.view.KeyEvent.ACTION_UP)
{
android.view.KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState();
if (state != null)
{
state.handleUpEvent(@event);
}
if (@event.isTracking() && [email protected]())
{
dismiss();
return true;
}
}
}
}
return false;
}
示例13: onSuggestionsKey
/// <summary>React to the user typing while in the suggestions list.</summary>
/// <remarks>
/// React to the user typing while in the suggestions list. First, check for
/// action keys. If not handled, try refocusing regular characters into the
/// EditText.
/// </remarks>
private bool onSuggestionsKey(android.view.View v, int keyCode, android.view.KeyEvent
@event)
{
// guard against possible race conditions (late arrival after dismiss)
if (mSearchable == null)
{
return false;
}
if (mSuggestionsAdapter == null)
{
return false;
}
if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.hasNoModifiers
())
{
// First, check for enter or search (both of which we'll treat as a
// "click")
if (keyCode == android.view.KeyEvent.KEYCODE_ENTER || keyCode == android.view.KeyEvent
.KEYCODE_SEARCH || keyCode == android.view.KeyEvent.KEYCODE_TAB)
{
int position = mQueryTextView.getListSelection();
return onItemClicked(position, android.view.KeyEvent.KEYCODE_UNKNOWN, null);
}
// Next, check for left/right moves, which we use to "return" the
// user to the edit view
if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT || keyCode == android.view.KeyEvent
.KEYCODE_DPAD_RIGHT)
{
// give "focus" to text editor, with cursor at the beginning if
// left key, at end if right key
// TODO: Reverse left/right for right-to-left languages, e.g.
// Arabic
int selPoint = (keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView
.length();
mQueryTextView.setSelection(selPoint);
mQueryTextView.setListSelection(0);
mQueryTextView.clearListSelection();
mQueryTextView.ensureImeVisible(true);
return true;
}
// Next, check for an "up and out" move
if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection
())
{
// TODO: restoreUserQuery();
// let ACTV complete the move
return false;
}
// Next, check for an "action key"
android.app.SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode
);
if ((actionKey != null) && ((actionKey.getSuggestActionMsg() != null) || (actionKey
.getSuggestActionMsgColumn() != null)))
{
// launch suggestion using action key column
int position = mQueryTextView.getListSelection();
if (position != android.widget.AdapterView.INVALID_POSITION)
{
android.database.Cursor c = mSuggestionsAdapter.getCursor();
if (c.moveToPosition(position))
{
string actionMsg = getActionKeyMessage(c, actionKey);
if (actionMsg != null && (actionMsg.Length > 0))
{
return onItemClicked(position, keyCode, actionMsg);
}
}
}
}
}
return false;
}
示例14: onGenericMotionEvent
/// <summary>Checks a generic motion event.</summary>
/// <remarks>Checks a generic motion event.</remarks>
/// <param name="event">The event.</param>
/// <param name="nestingLevel">
/// The nesting level: 0 if called from the base class,
/// or 1 from a subclass. If the event was already checked by this consistency verifier
/// at a higher nesting level, it will not be checked again. Used to handle the situation
/// where a subclass dispatching method delegates to its superclass's dispatching method
/// and both dispatching methods call into the consistency verifier.
/// </param>
public void onGenericMotionEvent(android.view.MotionEvent @event, int nestingLevel
)
{
if (!startEvent(@event, nestingLevel, EVENT_TYPE_GENERIC_MOTION))
{
return;
}
try
{
ensureMetaStateIsNormalized(@event.getMetaState());
int action = @event.getAction();
int source = @event.getSource();
if ((source & android.view.InputDevice.SOURCE_CLASS_POINTER) != 0)
{
switch (action)
{
case android.view.MotionEvent.ACTION_HOVER_ENTER:
{
ensurePointerCountIsOneForThisAction(@event);
mHoverEntered = true;
break;
}
case android.view.MotionEvent.ACTION_HOVER_MOVE:
{
ensurePointerCountIsOneForThisAction(@event);
break;
}
case android.view.MotionEvent.ACTION_HOVER_EXIT:
{
ensurePointerCountIsOneForThisAction(@event);
if (!mHoverEntered)
{
problem("ACTION_HOVER_EXIT without prior ACTION_HOVER_ENTER");
}
mHoverEntered = false;
break;
}
case android.view.MotionEvent.ACTION_SCROLL:
{
ensureHistorySizeIsZeroForThisAction(@event);
ensurePointerCountIsOneForThisAction(@event);
break;
}
default:
{
problem("Invalid action for generic pointer event.");
break;
}
}
}
else
{
if ((source & android.view.InputDevice.SOURCE_CLASS_JOYSTICK) != 0)
{
switch (action)
{
case android.view.MotionEvent.ACTION_MOVE:
{
ensurePointerCountIsOneForThisAction(@event);
break;
}
default:
{
problem("Invalid action for generic joystick event.");
break;
}
}
}
}
}
finally
{
finishEvent();
}
}
示例15: onTouchEvent
/// <summary>Checks a touch event.</summary>
/// <remarks>Checks a touch event.</remarks>
/// <param name="event">The event.</param>
/// <param name="nestingLevel">
/// The nesting level: 0 if called from the base class,
/// or 1 from a subclass. If the event was already checked by this consistency verifier
/// at a higher nesting level, it will not be checked again. Used to handle the situation
/// where a subclass dispatching method delegates to its superclass's dispatching method
/// and both dispatching methods call into the consistency verifier.
/// </param>
public void onTouchEvent(android.view.MotionEvent @event, int nestingLevel)
{
if (!startEvent(@event, nestingLevel, EVENT_TYPE_TOUCH))
{
return;
}
int action = @event.getAction();
bool newStream = action == android.view.MotionEvent.ACTION_DOWN || action == android.view.MotionEvent
.ACTION_CANCEL;
if (newStream && (mTouchEventStreamIsTainted || mTouchEventStreamUnhandled))
{
mTouchEventStreamIsTainted = false;
mTouchEventStreamUnhandled = false;
mTouchEventStreamPointers = 0;
}
if (mTouchEventStreamIsTainted)
{
@event.setTainted(true);
}
try
{
ensureMetaStateIsNormalized(@event.getMetaState());
int deviceId = @event.getDeviceId();
int source = @event.getSource();
if (!newStream && mTouchEventStreamDeviceId != -1 && (mTouchEventStreamDeviceId !=
deviceId || mTouchEventStreamSource != source))
{
problem("Touch event stream contains events from multiple sources: " + "previous device id "
+ mTouchEventStreamDeviceId + ", previous source " + Sharpen.Util.IntToHexString
(mTouchEventStreamSource) + ", new device id " + deviceId + ", new source " + Sharpen.Util.IntToHexString
(source));
}
mTouchEventStreamDeviceId = deviceId;
mTouchEventStreamSource = source;
int pointerCount = @event.getPointerCount();
if ((source & android.view.InputDevice.SOURCE_CLASS_POINTER) != 0)
{
switch (action)
{
case android.view.MotionEvent.ACTION_DOWN:
{
if (mTouchEventStreamPointers != 0)
{
problem("ACTION_DOWN but pointers are already down. " + "Probably missing ACTION_UP from previous gesture."
);
}
ensureHistorySizeIsZeroForThisAction(@event);
ensurePointerCountIsOneForThisAction(@event);
mTouchEventStreamPointers = 1 << @event.getPointerId(0);
break;
}
case android.view.MotionEvent.ACTION_UP:
{
ensureHistorySizeIsZeroForThisAction(@event);
ensurePointerCountIsOneForThisAction(@event);
mTouchEventStreamPointers = 0;
mTouchEventStreamIsTainted = false;
break;
}
case android.view.MotionEvent.ACTION_MOVE:
{
int expectedPointerCount = Sharpen.Util.IntGetBitCount(mTouchEventStreamPointers);
if (pointerCount != expectedPointerCount)
{
problem("ACTION_MOVE contained " + pointerCount + " pointers but there are currently "
+ expectedPointerCount + " pointers down.");
mTouchEventStreamIsTainted = true;
}
break;
}
case android.view.MotionEvent.ACTION_CANCEL:
{
mTouchEventStreamPointers = 0;
mTouchEventStreamIsTainted = false;
break;
}
case android.view.MotionEvent.ACTION_OUTSIDE:
{
if (mTouchEventStreamPointers != 0)
{
problem("ACTION_OUTSIDE but pointers are still down.");
}
ensureHistorySizeIsZeroForThisAction(@event);
ensurePointerCountIsOneForThisAction(@event);
mTouchEventStreamIsTainted = false;
break;
//.........这里部分代码省略.........