当前位置: 首页>>代码示例>>Java>>正文


Java KeyEventCompat类代码示例

本文整理汇总了Java中android.support.v4.view.KeyEventCompat的典型用法代码示例。如果您正苦于以下问题:Java KeyEventCompat类的具体用法?Java KeyEventCompat怎么用?Java KeyEventCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeyEventCompat类属于android.support.v4.view包,在下文中一共展示了KeyEventCompat类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:DirectionalViewpager.java

示例2: 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;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:29,代码来源:CustomViewAbove.java

示例3: 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;
}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:34,代码来源:CustomViewAbove.java

示例4: dispatchKeyEvent

import android.support.v4.view.KeyEventCompat; //导入依赖的package包/类
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getKeyCode() == 19) {
        int action = event.getAction();
        if (action == 0) {
            if (KeyEventCompat.hasModifiers(event, 2)) {
                ActionBar actionBar = getSupportActionBar();
                if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                    this.mEatKeyUpEvent = true;
                    return true;
                }
            }
        } else if (action == 1 && this.mEatKeyUpEvent) {
            this.mEatKeyUpEvent = false;
            return true;
        }
    }
    return super.dispatchKeyEvent(event);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:AppCompatActivity.java

示例5: 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;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:SearchView.java

示例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;
}
 
开发者ID:smuyyh,项目名称:SprintNBA,代码行数:34,代码来源:VerticalViewPager.java


注:本文中的android.support.v4.view.KeyEventCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。