本文整理汇总了Java中android.support.v4.view.KeyEventCompat.hasNoModifiers方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEventCompat.hasNoModifiers方法的具体用法?Java KeyEventCompat.hasNoModifiers怎么用?Java KeyEventCompat.hasNoModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.KeyEventCompat
的用法示例。
在下文中一共展示了KeyEventCompat.hasNoModifiers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例2: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例3: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* 执行按键响应事件
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例4: onSuggestionsKey
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) {
if (this.mSearchable == null || this.mSuggestionsAdapter == null || event.getAction() != 0 || !KeyEventCompat.hasNoModifiers(event)) {
return false;
}
if (keyCode == 66 || keyCode == 84 || keyCode == 61) {
return onItemClicked(this.mSearchSrcTextView.getListSelection(), 0, null);
}
if (keyCode != 21 && keyCode != 22) {
return (keyCode == 19 && this.mSearchSrcTextView.getListSelection() == 0) ? false : false;
} else {
int selPoint;
if (keyCode == 21) {
selPoint = 0;
} else {
selPoint = this.mSearchSrcTextView.length();
}
this.mSearchSrcTextView.setSelection(selPoint);
this.mSearchSrcTextView.setListSelection(0);
this.mSearchSrcTextView.clearListSelection();
HIDDEN_METHOD_INVOKER.ensureImeVisible(this.mSearchSrcTextView, true);
return true;
}
}
示例5: handleKeyScroll
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
private boolean handleKeyScroll(KeyEvent event, int count, int direction) {
boolean handled = false;
if (KeyEventCompat.hasNoModifiers(event)) {
handled = resurrectSelectionIfNeeded();
if (!handled) {
while (count-- > 0) {
if (arrowScroll(direction)) {
handled = true;
} else {
break;
}
}
}
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_ALT_ON)) {
handled = resurrectSelectionIfNeeded() || fullScroll(direction);
}
return handled;
}
示例6: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event
* The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and
// FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those
// devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例7: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event)
{
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (event.getKeyCode())
{
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11)
{
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event))
{
handled = arrowScroll(FOCUS_FORWARD);
}
else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON))
{
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例8: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (DEBUG) Log.d(TAG, "======executeKeyEvent is KEYCODE_DPAD_LEFT");
if (isOrientationHorizontal())
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (DEBUG) Log.d(TAG, "======executeKeyEvent is KEYCODE_DPAD_RIGHT");
if (isOrientationHorizontal())
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_DPAD_UP:
if (DEBUG) Log.d(TAG, "======executeKeyEvent is KEYCODE_DPAD_UP");
if (!isOrientationHorizontal())
handled = arrowScroll(FOCUS_UP);
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (DEBUG) Log.d(TAG, "======executeKeyEvent is KEYCODE_DPAD_DOWN");
if (!isOrientationHorizontal())
handled = arrowScroll(FOCUS_DOWN);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例9: onKey
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
public final boolean onKey(View paramAnonymousView, int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent)
{
if (SearchView.this.mSearchable == null) {}
do
{
return false;
if ((SearchView.this.mSearchSrcTextView.isPopupShowing()) && (SearchView.this.mSearchSrcTextView.getListSelection() != -1)) {
return SearchView.this.onSuggestionsKey(paramAnonymousView, paramAnonymousInt, paramAnonymousKeyEvent);
}
} while ((SearchView.SearchAutoComplete.access$1600(SearchView.this.mSearchSrcTextView)) || (!KeyEventCompat.hasNoModifiers(paramAnonymousKeyEvent)) || (paramAnonymousKeyEvent.getAction() != 1) || (paramAnonymousInt != 66));
paramAnonymousView.cancelLongPress();
SearchView.this.launchQuerySearch(0, null, SearchView.this.mSearchSrcTextView.getText().toString());
return true;
}
示例10: onSuggestionsKey
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
private boolean onSuggestionsKey(View paramView, int paramInt, KeyEvent paramKeyEvent)
{
if (this.mSearchable == null) {}
do
{
do
{
return false;
} while ((this.mSuggestionsAdapter == null) || (paramKeyEvent.getAction() != 0) || (!KeyEventCompat.hasNoModifiers(paramKeyEvent)));
if ((paramInt == 66) || (paramInt == 84) || (paramInt == 61)) {
return onItemClicked(this.mSearchSrcTextView.getListSelection(), 0, null);
}
if ((paramInt == 21) || (paramInt == 22))
{
if (paramInt == 21) {}
for (int i = 0;; i = this.mSearchSrcTextView.length())
{
this.mSearchSrcTextView.setSelection(i);
this.mSearchSrcTextView.setListSelection(0);
this.mSearchSrcTextView.clearListSelection();
HIDDEN_METHOD_INVOKER.ensureImeVisible$3d4581ed(this.mSearchSrcTextView);
return true;
}
}
} while ((paramInt != 19) || (this.mSearchSrcTextView.getListSelection() != 0));
return false;
}
示例11: onSuggestionsKey
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
private boolean onSuggestionsKey(View view, int i, KeyEvent keyevent)
{
if (mSearchable != null && mSuggestionsAdapter != null && keyevent.getAction() == 0 && KeyEventCompat.hasNoModifiers(keyevent))
{
if (i == 66 || i == 84 || i == 61)
{
return onItemClicked(mSearchSrcTextView.getListSelection(), 0, null);
}
if (i == 21 || i == 22)
{
if (i == 21)
{
i = 0;
} else
{
i = mSearchSrcTextView.length();
}
mSearchSrcTextView.setSelection(i);
mSearchSrcTextView.setListSelection(0);
mSearchSrcTextView.clearListSelection();
HIDDEN_METHOD_INVOKER.ensureImeVisible(mSearchSrcTextView, true);
return true;
}
if (i == 19 && mSearchSrcTextView.getListSelection() == 0)
{
return false;
}
}
return false;
}
示例12: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
if (isOrientationHorizontal())
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (isOrientationHorizontal())
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_DPAD_UP:
if (!isOrientationHorizontal())
handled = arrowScroll(FOCUS_UP);
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (!isOrientationHorizontal())
handled = arrowScroll(FOCUS_DOWN);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例13: executeKeyEvent
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event
* The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and
// FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those
// devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例14: onKey
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
public boolean onKey(View v, int keyCode, KeyEvent event) {
// guard against possible race conditions
if (mSearchable == null) {
return false;
}
if (DBG) {
Log.d(LOG_TAG, "mTextListener.onKey(" + keyCode + "," + event + "), selection: "
+ mQueryTextView.getListSelection());
}
// If a suggestion is selected, handle enter, search key, and action keys
// as presses on the selected suggestion
if (mQueryTextView.isPopupShowing()
&& mQueryTextView.getListSelection() != ListView.INVALID_POSITION) {
return onSuggestionsKey(v, keyCode, event);
}
// If there is text in the query box, handle enter, and action keys
// The search key is handled by the dialog's onKeyDown().
if (!mQueryTextView.isEmpty() && KeyEventCompat.hasNoModifiers(event)) {
if (event.getAction() == KeyEvent.ACTION_UP) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
v.cancelLongPress();
// Launch as a regular search.
launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, mQueryTextView.getText()
.toString());
return true;
}
}
if (event.getAction() == KeyEvent.ACTION_DOWN) {
// TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
// TODO if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) {
// TODO launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView
// TODO .getText().toString());
// TODO return true;
// TODO }
}
}
return false;
}
示例15: onSuggestionsKey
import android.support.v4.view.KeyEventCompat; //导入方法依赖的package包/类
/**
* 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.
*/
private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) {
// guard against possible race conditions (late arrival after dismiss)
if (mSearchable == null) {
return false;
}
if (mSuggestionsAdapter == null) {
return false;
}
if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) {
// First, check for enter or search (both of which we'll treat as a
// "click")
if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH
|| keyCode == KeyEvent.KEYCODE_TAB) {
int position = mQueryTextView.getListSelection();
return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null);
}
// Next, check for left/right moves, which we use to "return" the
// user to the edit view
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == 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 == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView
.length();
mQueryTextView.setSelection(selPoint);
mQueryTextView.setListSelection(0);
mQueryTextView.clearListSelection();
ensureImeVisible(mQueryTextView, true);
return true;
}
// Next, check for an "up and out" move
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) {
// TODO: restoreUserQuery();
// let ACTV complete the move
return false;
}
// Next, check for an "action key"
// TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
// TODO if ((actionKey != null)
// TODO && ((actionKey.getSuggestActionMsg() != null) || (actionKey
// TODO .getSuggestActionMsgColumn() != null))) {
// TODO // launch suggestion using action key column
// TODO int position = mQueryTextView.getListSelection();
// TODO if (position != ListView.INVALID_POSITION) {
// TODO Cursor c = mSuggestionsAdapter.getCursor();
// TODO if (c.moveToPosition(position)) {
// TODO final String actionMsg = getActionKeyMessage(c, actionKey);
// TODO if (actionMsg != null && (actionMsg.length() > 0)) {
// TODO return onItemClicked(position, keyCode, actionMsg);
// TODO }
// TODO }
// TODO }
// TODO }
}
return false;
}